Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not access com.codename1.impl.android.AndroidNativeUtil From nativeInterface

Can not access com.codename1.impl.android.AndroidNativeUtil From nativeInterface in codenameone as this structure is not available in the CodenameOne.jar. Do I need to import any other jar in classpath? Need to access the activity of codenameOne from the native interface by the below code:

private static Activity activity() {
    return com.codename1.impl.android.AndroidNativeUtil.getActivity();
}

But I am getting this error while deploying:

Compiling with JDK Java compiler API.

/tmp/build313004297852547361xxx/MyApplication/src/main/java/com/mycompany/myapp/MyNativeImpl.java:46: error: cannot find symbol
private static Activity activity() {
               ^

 symbol:   class Activity

location: class MyNativeImpl /tmp/build313004297852547361xxx/MyApplication/src/main/java/com/codename1/impl/android/AndroidImplementation.java:4684: error: cannot find symbol if (android.support.v4.content.ContextCompat.checkSelfPermission(activity, ^ symbol: method checkSelfPermission(CodenameOneActivity,String) location: class ContextCompat /tmp/build313004297852547361xxx/MyApplication/src/main/java/com/codename1/impl/android/AndroidImplementation.java:7117: error: cannot find symbol if (android.support.v4.content.ContextCompat.checkSelfPermission(activity, ^ symbol: method checkSelfPermission(CodenameOneActivity,String) location: class ContextCompat /tmp/build313004297852547361xxx/MyApplication/src/main/java/com/codename1/impl/android/AndroidImplementation.java:7122: error: cannot find symbol if (!forceAsk && android.support.v4.app.ActivityCompat.shouldShowRequestPermissionRationale(activity, ^ symbol: method shouldShowRequestPermissionRationale(CodenameOneActivity,String) location: class ActivityCompat /tmp/build313004297852547361xxx/MyApplication/src/main/java/com/codename1/impl/android/AndroidImplementation.java:7135: error: cannot find symbol android.support.v4.app.ActivityCompat.requestPermissions(activity, ^ symbol: method requestPermissions(CodenameOneActivity,String[],int) location: class ActivityCompat /tmp/build313004297852547361xxx/MyApplication/src/main/java/com/codename1/impl/android/AndroidImplementation.java:7152: error: cannot find symbol return android.support.v4.content.ContextCompat.checkSelfPermission(activity, ^ symbol: method checkSelfPermission(CodenameOneActivity,String) location: class ContextCompat /tmp/build313004297852547361xxx/MyApplication/src/main/java/com/mycompany/myapp/MyNativeImpl.java:56: error: no suitable constructor found for Intent(MyNativeImpl,Class) Intent intent = new Intent(this, ^ constructor Intent.Intent(String,Uri) is not applicable (argument mismatch; MyNativeImpl cannot be converted to String) constructor Intent.Intent(Context,Class) is not applicable (argument mismatch; MyNativeImpl cannot be converted to Context)

like image 925
Priyanka Samanta Avatar asked Jan 22 '26 19:01

Priyanka Samanta


1 Answers

Notice that it will mark it as inaccessible in the IDE but when you send the builds to the servers it should work just fine.

This is mentioned in the native interfaces tutorial.

like image 50
Derek Johnson Avatar answered Jan 24 '26 09:01

Derek Johnson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!