i create a new android studio project , add new Module
and i get unity plugin by this path "D:\\Unity\\Editor\\Data\\PlaybackEngines\\AndroidPlayer\\Variations\\mono\\Release\\Classes"
i add classes.jar to mylibrary>libs right click "classes.jar" and add library
edit mylibrary>build.gradle ,like this
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
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 'release/AndroidPlugin.jar'
}
task exportJar(type: Copy) {
from('build/intermediates/bundles/release/')
into('release/')
include('classes.jar')
rename('classes.jar', 'AndroidPlugin.jar')
}
exportJar.dependsOn(deleteOldJar, build)
and add a java
package com.example.mylibrary;
import android.app.AlertDialog;
import com.unity3d.player.UnityPlayer;
import com.unity3d.player.UnityPlayerActivity;
public class GetUrl extends UnityPlayerActivity {
public static void Show(final String title, final String content)
{
UnityPlayer.currentActivity.runOnUiThread(new Runnable() {
public void run() {
AlertDialog.Builder builder = new AlertDialog.Builder(UnityPlayer.currentActivity);
builder.setTitle(title).setMessage(content).setCancelable(false).setPositiveButton("OK", null);
builder.show();
}
});
}
}
after Refresh , i open grable menu , double click createJar , but no any file spawn
I am looking for a lot of tutorials and follow, try a few hours, almost the same steps, but still no results, do you have any ideas? D:
delete the code:
task deleteOldJar(type: Delete) {
delete 'release/AndroidPlugin.jar'
}
task exportJar(type: Copy) {
from('build/intermediates/bundles/release/')
into('release/')
include('classes.jar')
rename('classes.jar', 'AndroidPlugin.jar')
}
exportJar.dependsOn(deleteOldJar, build)
And just double-click the build function under your mylibrary gradle actions. Then get the newly minted mylibrary-debug.aar
file from /YourAndroidProject/mylibrary/build/outputs/aar/mylibrary-debug.aar
and drag it into your Plugins/Android
folder in your unity project.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.