Quantcast
Channel: Questions in topic: "android sdk"
Viewing all articles
Browse latest Browse all 455

unity Exception:JNI:Init'd AndroidJavaObject with null prt!

$
0
0
when my program run at 5 line in Unity Test.cs, " AndroidJavaObject jo = jc.CallStatic("instance");", it throw out the exception as described and end up. Exception:JNI:Init'd AndroidJavaObject with null prt! at UnityEngine.AndroidJavaObject..ctor(IntPtr jobject)(0x00000)in:0 MainActivity.java public class MainActivity extends UnityPlayerActivity { private static MainActivity instance; private static Context context; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MainActivity.instance = this; context = getApplicationContext(); } public void InstallAPK(String path) { Log.d("debug","InstallAPK path"+path); File apkFile = new File(path); if(apkFile.exists()) { Log.d("debug","InstallAPK!"); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(apkFile),"application/vnd.android.package-archive"); context.startActivity(intent); } else { Log.d("debug","fiald file!"); } } public static MainActivity instance() { return instance; } } AndroidManifest.xml Unity Test.cs void OnGUI() { if(GUI.Button(new Rect(10,250,450,100),"Install")) { AndroidJavaClass jc = new AndroidJavaClass("com.cmd.kz3d.qihu.MainActivity"); AndroidJavaObject jo = jc.CallStatic("instance"); string path = Application.persistentDataPath+"/test.apk"; Debug.Log(path); if(!File.Exists(path)) { Debug.Log("not found"); } //jc.Call("InstallAPK", path); jc.Call("InstallAPK", path); } }

Viewing all articles
Browse latest Browse all 455

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>