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

application crash #88

Closed
kingkimohero69 opened this issue Dec 28, 2019 · 7 comments
Closed

application crash #88

kingkimohero69 opened this issue Dec 28, 2019 · 7 comments

Comments

@kingkimohero69
Copy link

I faced this error after open the app, unity indeed does not export libmain.so and other .so files , I made the apk and decompiled it and got libmain.so ,libil2cpp.so and other files i put them into unity export but invain

E/flutter (13362): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(39)] java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.rexraphael.flutterunitywidgetexample-TxKj4BthLTvMKnaWmKmMOw==/base.apk"],nativeLibraryDirectories=[/data/app/com.rexraphael.flutterunitywidgetexample-TxKj4BthLTvMKnaWmKmMOw==/lib/x86, /data/app/com.rexraphael.flutterunitywidgetexample-TxKj4BthLTvMKnaWmKmMOw==/base.apk!/lib/x86, /system/lib]]] couldn't find "libmain.so"

@kingkimohero69
Copy link
Author

I think it maybe because unity does not support x86 architecture anymore,is that right?
unity version 2019.3.0f3

@OGmetamonkey
Copy link

I ran into the same issue. Have yet to find a solution, so I changed directions to utilize the new Unity as a Library support.

Please let us know if you find a fix. Would be much more convenient for flutter development to use this widget.

@OGmetamonkey
Copy link

Here is my exact error:

E/flutter ( 9958): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(39)] java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.rexraphael.flutterunitywidgetexample-BcfwL8VOVFiWptQasnB55Q==/base.apk"],nativeLibraryDirectories=[/data/app/com.rexraphael.flutterunitywidgetexample-BcfwL8VOVFiWptQasnB55Q==/lib/x86, /data/app/com.rexraphael.flutterunitywidgetexample-BcfwL8VOVFiWptQasnB55Q==/base.apk!/lib/x86, /system/lib, /system/product/lib]]] couldn't find "libmain.so"

My build.gradle:

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 28

lintOptions {
    disable 'InvalidPackage'
}

defaultConfig {
    // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.rexraphael.flutterunitywidgetexample"
    minSdkVersion 19
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        // TODO: Add your own signing config for the release build.
        // Signing with the debug keys for now, so `flutter run --release` works.
        signingConfig signingConfigs.debug
    }
}
}

flutter {
    source '../..'
}

dependencies {
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

And settings.gradle:

include ':app', ':unity-classes'

def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()

def plugins = new Properties()
def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
if (pluginsFile.exists()) {
    pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
}

plugins.each { name, path ->
    def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
    include ":$name"
    project(":$name").projectDir = pluginDirectory
}

include ":UnityExport"
project(":UnityExport").projectDir = file("./UnityExport")

@subjectdenied
Copy link

i'm pretty sure i had this issue when using unity as a library with arfoundation and various other 3rd party unity libs, and not adding their aar-files inside UnityExport/libs as project-dependencies

if you have additional libs there other than unity-classes.jar, add them as modules like you did with unity-classes.jar, and in my case with latest unity 2019.3 beta build, change your build.gradle in UnityExport to use:

implementation project(':unity-classes') implementation project(':ARPresto') ...

for an example instead of having the dependencies added by their filenames directly (as the unity flutter export script does)

add all of those "projects" as includes to the "android" projects settings.gradle as you did with unity-classes and make sure you sync the gradle scripts

make sure the imported aar-files as modules are inside the UnityExport directory instead of the flutter project root, the chapter "Vuforia" in the readme hints about this (and also the way how to add the dependencies as written above), this finally made things work for me (well until i found issues with androidx libs, sdk versions and flutter-plugins, but that is whole other story ...)

@kingkimohero69
Copy link
Author

Thank you for your time@subjectdenied , I did the steps as you mentioned but i guess the core problem is that i used emulator which working only on x86 architecture and unity does not support x86 in the latest version , i ran into other problem when i install the app into my phone MI 9T
Screenshot_2020-01-02-18-58-32-387_com miui bugreport 1
Screenshot_2020-01-02-18-58-37-193_com miui bugreport 1
Screenshot_2020-01-02-18-58-42-366_com miui bugreport 1
Screenshot_2020-01-02-18-58-49-604_com miui bugreport 1

@winsw-dev
Copy link

Thank you for your time@subjectdenied , I did the steps as you mentioned but i guess the core problem is that i used emulator which working only on x86 architecture and unity does not support x86 in the latest version , i ran into other problem when i install the app into my phone MI 9T
Screenshot_2020-01-02-18-58-32-387_com miui bugreport 1
Screenshot_2020-01-02-18-58-37-193_com miui bugreport 1
Screenshot_2020-01-02-18-58-42-366_com miui bugreport 1
Screenshot_2020-01-02-18-58-49-604_com miui bugreport 1

I also got the same issue as you. I manage it to work by change isARScene: true, where dart file include the UnityWidget.

@kingkimohero69
Copy link
Author

yeah it works now , thank you @sarawin008 you solved my problem ,Thank you all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants