Why am I getting class not found exception with AndroidJavaClass?
up vote
0
down vote
favorite
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.build();
StrictMode.setThreadPolicy(policy);
I tried the following code, but generates exception for class not found for ThreadPolicy
#if UNITY_ANDROID
using (AndroidJavaClass strictModeClass = new AndroidJavaClass("android.os.StrictMode"))
{
using (AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode.ThreadPolicy"))
{
AndroidJavaObject Builder = threadpolicy.Call<AndroidJavaObject>("Builder");
AndroidJavaObject permitall = Builder.Call<AndroidJavaObject>("permitAll");
AndroidJavaObject build = permitall.Call<AndroidJavaObject>("build");
strictModeClass.Call<AndroidJavaObject>("setThreadPolicy", build);
}
}
#endif
c# unity3d android-unity-plugin
add a comment |
up vote
0
down vote
favorite
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.build();
StrictMode.setThreadPolicy(policy);
I tried the following code, but generates exception for class not found for ThreadPolicy
#if UNITY_ANDROID
using (AndroidJavaClass strictModeClass = new AndroidJavaClass("android.os.StrictMode"))
{
using (AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode.ThreadPolicy"))
{
AndroidJavaObject Builder = threadpolicy.Call<AndroidJavaObject>("Builder");
AndroidJavaObject permitall = Builder.Call<AndroidJavaObject>("permitAll");
AndroidJavaObject build = permitall.Call<AndroidJavaObject>("build");
strictModeClass.Call<AndroidJavaObject>("setThreadPolicy", build);
}
}
#endif
c# unity3d android-unity-plugin
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.build();
StrictMode.setThreadPolicy(policy);
I tried the following code, but generates exception for class not found for ThreadPolicy
#if UNITY_ANDROID
using (AndroidJavaClass strictModeClass = new AndroidJavaClass("android.os.StrictMode"))
{
using (AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode.ThreadPolicy"))
{
AndroidJavaObject Builder = threadpolicy.Call<AndroidJavaObject>("Builder");
AndroidJavaObject permitall = Builder.Call<AndroidJavaObject>("permitAll");
AndroidJavaObject build = permitall.Call<AndroidJavaObject>("build");
strictModeClass.Call<AndroidJavaObject>("setThreadPolicy", build);
}
}
#endif
c# unity3d android-unity-plugin
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder()
.detectAll()
.penaltyLog()
.build();
StrictMode.setThreadPolicy(policy);
I tried the following code, but generates exception for class not found for ThreadPolicy
#if UNITY_ANDROID
using (AndroidJavaClass strictModeClass = new AndroidJavaClass("android.os.StrictMode"))
{
using (AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode.ThreadPolicy"))
{
AndroidJavaObject Builder = threadpolicy.Call<AndroidJavaObject>("Builder");
AndroidJavaObject permitall = Builder.Call<AndroidJavaObject>("permitAll");
AndroidJavaObject build = permitall.Call<AndroidJavaObject>("build");
strictModeClass.Call<AndroidJavaObject>("setThreadPolicy", build);
}
}
#endif
c# unity3d android-unity-plugin
c# unity3d android-unity-plugin
edited Nov 8 at 16:55
Programmer
73.7k1076137
73.7k1076137
asked Nov 8 at 12:54
virtplay
120113
120113
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
It simply can't find the class on the Java side. This can be caused my misspelling, ProGuard obfuscating the class name or the package and plugin with the class not included in your project.
In your case, you get "class not found" exception at AndroidJavaClass("android.os.StrictMode.ThreadPolicy") because ThreadPolicy is not a package but an inner class so to differentiate between these two, you have to tell JRE that you are looking for an inner class and this can be done by replacing the "." in the inner class with the "$" symbol.
Replace
AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode.ThreadPolicy")
with
AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode$ThreadPolicy");
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
It simply can't find the class on the Java side. This can be caused my misspelling, ProGuard obfuscating the class name or the package and plugin with the class not included in your project.
In your case, you get "class not found" exception at AndroidJavaClass("android.os.StrictMode.ThreadPolicy") because ThreadPolicy is not a package but an inner class so to differentiate between these two, you have to tell JRE that you are looking for an inner class and this can be done by replacing the "." in the inner class with the "$" symbol.
Replace
AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode.ThreadPolicy")
with
AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode$ThreadPolicy");
add a comment |
up vote
0
down vote
It simply can't find the class on the Java side. This can be caused my misspelling, ProGuard obfuscating the class name or the package and plugin with the class not included in your project.
In your case, you get "class not found" exception at AndroidJavaClass("android.os.StrictMode.ThreadPolicy") because ThreadPolicy is not a package but an inner class so to differentiate between these two, you have to tell JRE that you are looking for an inner class and this can be done by replacing the "." in the inner class with the "$" symbol.
Replace
AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode.ThreadPolicy")
with
AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode$ThreadPolicy");
add a comment |
up vote
0
down vote
up vote
0
down vote
It simply can't find the class on the Java side. This can be caused my misspelling, ProGuard obfuscating the class name or the package and plugin with the class not included in your project.
In your case, you get "class not found" exception at AndroidJavaClass("android.os.StrictMode.ThreadPolicy") because ThreadPolicy is not a package but an inner class so to differentiate between these two, you have to tell JRE that you are looking for an inner class and this can be done by replacing the "." in the inner class with the "$" symbol.
Replace
AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode.ThreadPolicy")
with
AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode$ThreadPolicy");
It simply can't find the class on the Java side. This can be caused my misspelling, ProGuard obfuscating the class name or the package and plugin with the class not included in your project.
In your case, you get "class not found" exception at AndroidJavaClass("android.os.StrictMode.ThreadPolicy") because ThreadPolicy is not a package but an inner class so to differentiate between these two, you have to tell JRE that you are looking for an inner class and this can be done by replacing the "." in the inner class with the "$" symbol.
Replace
AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode.ThreadPolicy")
with
AndroidJavaClass threadpolicy = new AndroidJavaClass("android.os.StrictMode$ThreadPolicy");
answered Nov 8 at 17:21
Programmer
73.7k1076137
73.7k1076137
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53208180%2fwhy-am-i-getting-class-not-found-exception-with-androidjavaclass%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown