繁体   English   中英

统一 ARCORE DllNotFoundException: arcore_unity_api

[英]Unity ARCORE DllNotFoundException: arcore_unity_api

我尝试从 Unity 导出项目,然后将其作为库从 Android Studio 导出,但是当我将该库导入另一个项目时,出现错误:E/Unity:无法找到 arpresto_api

(如果我在不导出为库的情况下运行它,一切正常)

任何帮助将不胜感激。

已经尝试过Unity + ARCORE DllNotFoundException: arcore_unity_api但它不起作用。

gradle:


buildscript {
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.2'
}
}

allprojects {
    repositories {
        google()
        jcenter()
        flatDir {
            dirs 'libs'
        }
    }
}

apply plugin: 'com.android.library'


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation(name: 'arcore_client', ext:'aar')
    implementation(name: 'arcore_unity', ext:'aar')
    implementation(name: 'google_ar_required', ext:'aar')
    implementation(name: 'unityandroidpermissions', ext:'aar')
    implementation(name: 'unitygar', ext:'aar')
}

android {
    compileSdkVersion 26
    buildToolsVersion '28.0.3'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdkVersion 26
        targetSdkVersion 28
        ndk {
            abiFilters 'armeabi-v7a', 'x86'
        }
        versionCode 1
        versionName '0.1'
    }

    lintOptions {
        abortOnError false
    }

    aaptOptions {
        noCompress = ['.unity3d', '.ress', '.resource', '.obb']
    }

    buildTypes {
        debug {
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
            jniDebuggable true
        }
        release {
            minifyEnabled false
            useProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'
            signingConfig signingConfigs.debug
        }
    }

    packagingOptions {
        doNotStrip '*/armeabi-v7a/*.so'
        doNotStrip '*/x86/*.so'
    }

    splits {
        language {
            enable false
        }
        density {
            enable false
        }
        abi {
            enable true
        }
    }
}
E/Unity: Unable to find arpresto_api
E/Unity: DllNotFoundException: arcore_unity_api
        at (wrapper managed-to-native) GoogleARCoreInternal.ARPrestoCallbackManager+ExternApi.ArCoreUnity_setArPrestoInitialized(GoogleARCoreInternal.ARPrestoCallbackManager/EarlyUpdateCallback)
      at GoogleARCoreInternal.ARPrestoCallbackManager._Initialize () [0x0002c] in /Users/petrosmaliotis/New Unity Project 4/Assets/GoogleARCore/SDK/Scripts/Managers/ARPrestoCallbackManager.cs:181
      at GoogleARCoreInternal.ARPrestoCallbackManager.get_Instance () [0x00018] in /Users/petrosmaliotis/New Unity Project 4/Assets/GoogleARCore/SDK/Scripts/Managers/ARPrestoCallbackManager.cs:91
      at GoogleARCoreInternal.ARCoreAndroidLifecycleManager.get_Instance () [0x00023] in /Users/petrosmaliotis/New Unity Project 4/Assets/GoogleARCore/SDK/Scripts/Managers/ARCoreAndroidLifecycleManager.cs:80
      at GoogleARCoreInternal.LifecycleManager.get_Instance () [0x00029] in /Users/petrosmaliotis/New Unity Project 4/Assets/GoogleARCore/SDK/Scripts/Managers/LifecycleManager.cs:43
      at GoogleARCore.ARCoreS

通过将文件夹[ jniLibsassetslibs ]与库一起添加到我的项目中,从而设法解决了该问题。

当您将UnityProject导出为库时,这似乎是一个问题。

将这些文件夹从UnityProject(从Unity导出的版本)复制并粘贴到您导入库的项目中,然后在清单和Gradle(app)文件中进行一些更改。 确保文件夹位于正确的位置。

libs应该位于:yourApp / app / libs

jniLibs应该位于:yourApp / app / src / main / jniLibs

资产应位于:yourApp / app / src / main / 资产

摇篮更改。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "com.something.ar"
        minSdkVersion 26
        targetSdkVersion 28
        ndk {
            abiFilters 'armeabi-v7a', 'x86'
        }
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/'] } }

    aaptOptions {
        noCompress = ['.unity3d', '.ress', '.resource', '.obb']
    }

    packagingOptions {
        doNotStrip '*/armeabi-v7a/*.so'
        doNotStrip '*/x86/*.so'
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:support-v4:28.0.0'
    implementation(name: 'arcore_client', ext:'aar')
    implementation(name: 'arcore_unity', ext:'aar')
    implementation(name: 'google_ar_required', ext:'aar')
    implementation(name: 'unityandroidpermissions', ext:'aar')
    implementation(name: 'unitygar', ext:'aar')
    implementation project(':ar_demo')
    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'
}

清单文件。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.something.ar">

    <supports-screens
        android:anyDensity="true"
        android:largeScreens="true"
        android:normalScreens="true"
        android:smallScreens="true"
        android:xlargeScreens="true"/>

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>

        </activity>
        <meta-data
            android:name="unity.tango-enable"
            android:value="True"/>
        <meta-data
            android:name="unityplayer.SkipPermissionsDialog"
            android:value="true"/>
        <meta-data
            android:name="unity.build-id"
            android:value="a2756142-8f7a-45e0-95ae-a566f7d2a2a2"/>
        <meta-data
            android:name="unity.splash-mode"
            android:value="0"/>
        <meta-data
            android:name="unity.splash-enable"
            android:value="True"/>
    </application>

    <uses-feature android:glEsVersion="0x00020000"/>

    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.INTERNET"/>

    <uses-feature
        android:name="android.hardware.touchscreen"
        android:required="false"/>
    <uses-feature
        android:name="android.hardware.touchscreen.multitouch"
        android:required="false"/>
    <uses-feature
        android:name="android.hardware.touchscreen.multitouch.distinct"
        android:required="false"/>



</manifest>

其他可能的解决方案是修复自动生成的 Unity build.gradle 文件。 将依赖部分更改为

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    //implementation(name: 'arcore_client', ext:'aar')
    //implementation(name: 'ARPresto', ext:'aar')
    //implementation(name: 'unityandroidpermissions', ext:'aar')
    //implementation(name: 'UnityARCore', ext:'aar')

    implementation files('libs/arcore_client.aar')
    implementation files('libs/ARPresto.aar')
    implementation files('libs/unityandroidpermissions.aar')
    implementation files('libs/UnityARCore.aar')
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM