我试图从Unity导出这个项目,然后从Android导出它为一个库,但是当我将这个库导入到另一个项目时,我得到了错误: E/Unity:无法找到arpresto_api
(如果我在不作为库导出的情况下运行它,一切都很好)
任何帮助都会被接受。
已经尝试过api了,但它不起作用。
格莱德尔:
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
发布于 2019-04-24 21:58:17
通过将文件夹jniLibs、assets、libs与库一起添加到我的项目中,成功地解决了这个问题。
当您将UnityProject导出为库时,它似乎是一个问题。
将这些文件夹从UnityProject (从团结导出的版本)复制并粘贴到导入库的项目中,并在Manifest和Gradle (app)文件中进行一些更改。确保文件夹在正确的位置。
yourApp/app/libs中应该包含libs
应该在: yourApp/app/src/main/jniLibs中jniLibs
资产管理系统( yourApp/app/src/main/assets )应该在:
梯度变化。
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>
发布于 2022-04-25 21:30:32
其他可能的解决方案是修复自动生成的统一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')
}
https://stackoverflow.com/questions/55783814
复制相似问题