- Home /
How to extend UnityPlayerActivity
I am trying to extend the UnityPlayerActivity. I am using android studio 3.2.1. I copied the classes.jar from unity into the libs folder in my android studio project. I have added it as a library. The problem right now is when I open my app it immediately closes. I think maybe something is wrong with my gradle but I have no idea how to fix it. It might also be the name of the package. I'm not sure if they need to be the same but my android project currently has a different package name than my unity project. I've never extended the UnityPlayerActivity before so I'm sure I'm missing something simple.
Here is my gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions { abortOnError false }
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
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'
implementation files('libs/classes.jar')
}
task deleteOldJar(type: Delete) { delete 'libs/LRA2n1Activity.jar' }
task exportJar(type: Copy) { from('build/intermediates/intermediate-
jars/release/') into('libs/') include('classes.jar')
rename('classes.jar', 'LRA2n1Activity.jar') }
Here is my manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Immersion.LRA2n1"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="preferExternal">
<supports-screens android:smallScreens="true" android:normalScreens="true"
android:largeScreens="true" android:xlargeScreens="true"
android:anyDensity="true" />
<application android:theme="@style/UnityThemeSelector"
android:icon="@mipmap/app_icon" android:label="@string/app_name"
android:isGame="true" android:banner="@drawable/app_banner">
<activity android:label="@string/app_name"
android:screenOrientation="fullSensor" android:launchMode="singleTask"
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density"
android:hardwareAccelerated="false"
android:name=".LRA2n1Activity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
<meta-data android:name="unity.build-id" android:value="aeaded6f-49da-43d8-8b73-64c29a199a12" />
<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.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<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>
Any and all help will be greatly appreciated.
Your answer
Follow this Question
Related Questions
Can I use JDK 1.7 for Android plugins? 0 Answers
Extending the UnityPlayerActivity Java Code fail to build 1 Answer
AndroidJava and Implementing java.util.List 0 Answers
Android manifest does not merge with generated manifest. 0 Answers
How to get Application.PersistentDataPath inside a Java Android Plugin 1 Answer