Мне удалось решить эту проблему, добавив папки [ jniLibs , assets , libs ] в мой проект вместе с библиотекой.
Кажется, это проблема при экспорте UnityProject в виде библиотеки.
Скопируйте и вставьте эти папки из UnityProject (экспортированная версия из Unity) в проект, в который вы импортировали свою библиотеку, и внесите некоторые изменения в файл Manifest и Gradle (приложение).
Убедитесь, что папки находятся в правильном месте.
libs должно быть в: yourApp / app / libs
jniLibs должен быть в: yourApp / app / src / main / jniLibs
assets должны находиться в: yourApp / app / src / main / assets
Изменения Gradle.
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>