Android plugin in Unity

Viewed 259

i am trying to add a local .aar from an android library in Unity. Currently it is a very basic project, in unity there is just one script that opens the activity from android library on a button click.

I manually added the .aar in the /plugins/android folder (I am using 2019.4 version), and on build I keep getting the error that a resource is not found (Theme.AppCompat.Light.NoActionBar' not found in AndroidManifest) .

This are my graddle config & AndroidManifest:

plugins {
    id 'com.android.library'
}

android {
    compileSdk 31

    defaultConfig {
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    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 "com.facebook.react:react-native:+"

    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
    implementation 'com.google.android.material:material:1.4.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

//(MainApplication) Manual ReactPackage Setup here...
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
applyNativeModulesAppBuildGradle(project)
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example">
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        android:name=".MainApplication"
        android:allowBackup="true"
        android:usesCleartextTraffic="true"
        android:supportsRtl="true"
        >
        <activity android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
        <activity
            android:name=".ReactNativeActivity"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
            android:windowSoftInputMode="adjustResize" />
    </application>
</manifest>

I am a newbie when it comes to mobile development, but I think the issue is that the dependencies from build.graddle are not included in the .aar. I think my options are to either create a fat .aar , manually download dependencies .aar's or to publish .aar to a central repository. Am I on the right track?

Any help is more than appriciated

1 Answers

I manage to get over the error by adding a custom graddle template to the unity project.

Related