Open a shell and make sure there exist an NDK global variable set to
the directory where you extracted the NDK.
1 2 3 4 5
sudo gedit ~/.bashrc
export ANDROID_SDK=<path to Android SDK directory> export ANDROID_NDK=<path to Android NDK directory> export PATH=$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools:$ANDROID_NDK
1 2 3 4 5 6 7 8 9
source ~/.bashrc ndk-build --version
GNU Make 4.2.1 Built for x86_64-pc-linux-gnu Copyright (C) 1988-2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
//task to export contents as jar task exportJar(type: Copy) { from('build/intermediates/aar_main_jar/release/') into('release/') include('classes.jar') ///Rename the jar rename('classes.jar', 'AndroidPlugin.jar') }
exportJar.dependsOn(deleteOldJar, build)
Android
Studio中执行Sync Project with Gradle Files,然后在右上角Gradle中Module name/Task/other/下执行exportJar:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class test : MonoBehaviour { // Start is called before the first frame update void Awake() { Debug.Log("=================="); AndroidJavaObject activity = new AndroidJavaObject ("com.cvte.imagetracker.MainActivity"); Debug.Log("GetRoot"); activity.Call("GetRoot"); Debug.Log("=================="); }
// Update is called once per frame void Update() { }