Unity-Technologies / uaal-example

Other
736 stars 234 forks source link

[Android-Bug] Clicked the Show Unity Button is crash #33

Open weacw opened 3 years ago

weacw commented 3 years ago

I tried to change the gradle version to 3.x.x and it is working. But the new project of Android Studio 4.x does not work properly.

And tried the following solutions but it still does not work: https://github.com/f111fei/react-native-unity-view/issues/142#issue-523429382

Info

build.gradle(PROJECT:APP):

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 28
    buildToolsVersion "30.0.2"

    defaultConfig {
        applicationId "com.cell.ardemo2"
        minSdkVersion 24
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation project(':unityLibrary')
    implementation fileTree(dir: project(':unityLibrary').getProjectDir().toString() + ('\\libs'), include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

build.gradle(PROJECT):

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.1.0"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs "${project(':unityLibrary').projectDir}/libs"
        }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

Log:

2020-10-31 20:09:20.061 4569-4569/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.cell.ardemo2:Unity, PID: 4569
    java.lang.UnsatisfiedLinkError: dlopen failed: library "libmain.so" not found
        at java.lang.Runtime.loadLibrary0(Runtime.java:1087)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1008)
        at java.lang.System.loadLibrary(System.java:1664)
        at com.unity3d.player.UnityPlayer.<clinit>(Unknown Source:13)
        at com.unity3d.player.UnityPlayerActivity.onCreate(UnityPlayerActivity.java:41)
        at com.company.product.OverrideUnityActivity.onCreate(OverrideUnityActivity.java:16)
        at android.app.Activity.performCreate(Activity.java:8000)
        at android.app.Activity.performCreate(Activity.java:7984)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
HosseinB5017 commented 3 years ago

and crash for me too with this erorr Unity: Failed to load 'libmain.so', the application will terminate.

methusalah commented 3 years ago

Same error here: Failure to initialize! Your hardware does not support this application. Failed to load 'libmain.so'

Android Studio 4.1.1, gradle 6.5, Unity 2020.1.14, with Android API level 29 hardware.

Edit : Adding this to my app level build.gradle file solved the issue

defaultConfig {
        ndk {
            abiFilters 'armeabi-v7a', 'x86'
        }
    }
zhuyiif commented 3 years ago

same issue ,dong't know how to fix

zhuyiif commented 3 years ago

change gradle version to 3.4 works

KainanSu commented 2 years ago

change gradle version to 3.4 works

cannt sovle

KainanSu commented 2 years ago

If an error occurs in a higher version Unity: Failed to load 'libmain.so', the application will terminate.

Try the following method https://github.com/f111fei/react-native-unity-view/issues/142#issuecomment-557162700