Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Cannot link executable #20715

Closed
MrmaderatorYT opened this issue May 30, 2024 · 2 comments
Closed

[Bug]: Cannot link executable #20715

MrmaderatorYT opened this issue May 30, 2024 · 2 comments
Labels
bug report Something is not working properly.

Comments

@MrmaderatorYT
Copy link

Problem description

Have an error:

CANNOT LINK EXECUTABLE "aapt2": cannot locate symbol "__emutls_get_address" referenced by "/data/data/com.termux/files/usr/bin/aapt2"...
Помилка створення APK файлу

I have script:

#!/data/data/com.termux/files/usr/bin/sh

# Додайте PATH
export PATH=$PATH:/data/data/com.termux/files/usr/bin

echo "=== Starting script ==="

pkg update -y
pkg upgrade -y
pkg install -y openjdk-17 dx ecj aapt2 termux-api
sudo apt update && sudo apt full-upgrade -y

pkg update -y
pkg upgrade -y
echo "=== Packages installed ==="

# Параметри
APP_NAME="MyApp"
PACKAGE_NAME="com.example.myapp"
MAIN_ACTIVITY="MainActivity"
SOURCE_DIR="/storage/emulated/0/Documents/GenCoreLite/scripts/src"
BUILD_DIR="/storage/emulated/0/Documents/GenCoreLite/scripts/build"
OUTPUT_DIR="/storage/emulated/0/Documents/GenCoreLite/scripts/output"
MANIFEST_FILE="AndroidManifest.xml"

MAIN_ACTIVITY_CODE="
package $PACKAGE_NAME;

import android.app.Activity;
import android.os.Bundle;

public class $MAIN_ACTIVITY extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Тут можна додати ваш код
    }
}
"

echo "=== Parameters set ==="

MANIFEST_CONTENT="
<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"
    package=\"$PACKAGE_NAME\">
    <application
        android:allowBackup=\"true\"
        android:icon=\"@mipmap/ic_launcher\"
        android:label=\"$APP_NAME\"
        android:roundIcon=\"@mipmap/ic_launcher_round\"
        android:supportsRtl=\"true\"
        android:theme=\"@style/Theme.MyApp\">
        <activity android:name=\".$MAIN_ACTIVITY\">
            <intent-filter>
                <action android:name=\"android.intent.action.MAIN\" />
                <category android:name=\"android.intent.category.LAUNCHER\" />
            </intent-filter>
        </activity>
    </application>
</manifest>
"

# Створення необхідних директорій
mkdir -p $SOURCE_DIR/$PACKAGE_NAME
chmod 777 $SOURCE_DIR/$PACKAGE_NAME

mkdir -p $BUILD_DIR
chmod 777 $BUILD_DIR

mkdir -p $OUTPUT_DIR
chmod 777 $OUTPUT_DIR

mkdir -p res/mipmap
chmod 777 res/mipmap

echo "=== Directories created ==="

# Створення основного Java файлу
echo "$MAIN_ACTIVITY_CODE" > $SOURCE_DIR/$PACKAGE_NAME/$MAIN_ACTIVITY.java

# Створення AndroidManifest.xml
echo "$MANIFEST_CONTENT" > $MANIFEST_FILE

# Створення placeholder іконок
touch res/mipmap/ic_launcher.png
touch res/mipmap/ic_launcher_round.png

echo "=== Files created ==="

# Перевірка наявності файлів
echo "=== Checking files ==="
ls -R $SOURCE_DIR
ls -R res
cat $MANIFEST_FILE

echo "=== Компліяція Java файлів ==="
ecj -d $BUILD_DIR $SOURCE_DIR/$PACKAGE_NAME/$MAIN_ACTIVITY.java
if [ $? -ne 0 ]; then
    echo "Помилка компіляції Java файлів"
    exit 1
fi
pkg update -y
pkg upgrade -y
echo "=== Перетворення класів в DEX файл ==="
# Перетворення класів в DEX файл
dx --dex --output=$BUILD_DIR/classes.dex $BUILD_DIR
if [ $? -ne 0 ]; then
    echo "Помилка перетворення класів в DEX файл"
    exit 1
fi
pkg update -y
pkg upgrade -y
echo "=== Створення APK файлу ==="
aapt2 compile -o $BUILD_DIR/res.zip res/
aapt2 link -o $OUTPUT_DIR/$APP_NAME.apk -I $PREFIX/share/aapt/android.jar --manifest $MANIFEST_FILE --java $BUILD_DIR $BUILD_DIR/res.zip
if [ $? -ne 0 ]; then
    echo "Помилка створення APK файлу"
    exit 1
fi
pkg update -y
pkg upgrade -y
echo "=== Додавання Dex файлу в APK ==="
aapt2 add $OUTPUT_DIR/$APP_NAME.apk $BUILD_DIR/classes.dex
if [ $? -ne 0 ]; then
    echo "Помилка додавання DEX файлу в APK"
    exit 1
fi
pkg update -y
pkg upgrade -y
# Очищення
rm -rf $BUILD_DIR

echo "APK створено: $OUTPUT_DIR/$APP_NAME.apk"

Steps to reproduce the behavior.

I reinstalled termux;
I added:

pkg update -y
pkg upgrade -y

Nothing happened

What is the expected behavior?

No response

System information

  • Termux application version: 0.118
  • Android OS version: 14
  • Device model: aarch64
@MrmaderatorYT MrmaderatorYT added the bug report Something is not working properly. label May 30, 2024
@thunder-coding
Copy link
Member

thunder-coding commented Jun 5, 2024

https://github.com/termux/termux-app is for bug reports for the app itself. For any issues with any packages, you should report the bugs here: https://github.com/termux/termux-packages

Also, I'm unable to reproduce the bug locally. Try changing your mirrors with termux-change-repo and then update your packages.

@Grimler91 Grimler91 transferred this issue from termux/termux-app Jun 28, 2024
@Grimler91
Copy link
Member

Also cannot reproduce. The __emutls_get_address error happened some years ago when we switched upgraded the ndk used, and corresponding ndk-* and libc++ packages, so seems likely that issue was/is caused by partially upgraded packages. Script runs apt update && apt upgrade and so on though, but maybe an outdated mirror is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Something is not working properly.
Projects
None yet
Development

No branches or pull requests

3 participants