Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to build L2CAPContext.java and Peripheral.java #977

Closed
nikolaof opened this issue Jun 6, 2023 · 2 comments · Fixed by #978
Closed

Failed to build L2CAPContext.java and Peripheral.java #977

nikolaof opened this issue Jun 6, 2023 · 2 comments · Fixed by #978
Milestone

Comments

@nikolaof
Copy link

nikolaof commented Jun 6, 2023

Hello.

I'm trying to build an ionic project that uses this plugin and 4 months earlier I was able to build it but no more.

More specifically here is what I'm getting:

/home/user/dev/ionic-app/platforms/android/app/src/main/java/com/megster/cordova/ble/central/Peripheral.java:35: error: cannot find symbol
import androidx.annotation.RequiresPermission;
                          ^
  symbol:   class RequiresPermission
  location: package androidx.annotation
/home/user/dev/ionic-app/platforms/android/app/src/main/java/com/megster/cordova/ble/central/L2CAPContext.java:6: error: cannot find symbol
import androidx.annotation.RequiresApi;
                          ^
  symbol:   class RequiresApi
  location: package androidx.annotation
/home/user/dev/ionic-app/platforms/android/app/src/main/java/com/megster/cordova/ble/central/Peripheral.java:1000: error: cannot find symbol
    @RequiresPermission("android.permission.BLUETOOTH_CONNECT")
     ^
  symbol:   class RequiresPermission
  location: class Peripheral
/home/user/dev/ionic-app/platforms/android/app/src/main/java/com/megster/cordova/ble/central/Peripheral.java:1028: error: cannot find symbol
    @RequiresPermission("android.permission.BLUETOOTH_CONNECT")
     ^
  symbol:   class RequiresPermission
  location: class Peripheral
/home/user/dev/ionic-app/platforms/android/app/src/main/java/com/megster/cordova/ble/central/Peripheral.java:1076: error: cannot find symbol
    @RequiresPermission("android.permission.BLUETOOTH_CONNECT")
     ^
  symbol:   class RequiresPermission
  location: class Peripheral
/home/user/dev/ionic-app/platforms/android/app/src/main/java/com/megster/cordova/ble/central/L2CAPContext.java:110: error: cannot find symbol
    @RequiresApi(api = Build.VERSION_CODES.M)
     ^
  symbol:   class RequiresApi
  location: class L2CAPContext
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
6 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileReleaseJavaWithJavac'.

The environment of mine is quite old but I'm not sure if that's the issue.

$ npm list -g

/home/user/.nvm/versions/node/v16.9.0/lib
├── @angular/cli@8.3.29
├── @ionic/cli@6.17.1
├── cordova@10.0.0
├── ionic@5.4.16
└── npm@7.21.1

$ java -version
java version "1.8.0_301"

In Ionic's config file I have set <preference name="android-targetSdkVersion" value="31" />

Plugin's version: 1.7.0

@peitschie
Copy link
Collaborator

Hi @nikolaof

This sounds very similar to #957

I've raised #978 to add the missing dependency, but I suspect you'll run into a permissions issue next like this:

ERROR:/home/runner/work/cordova-plugin-ble-central/cordova-plugin-ble-central/temp/android/app/build/intermediates/packaged_manifests/debug/AndroidManifest.xml:26: AAPT: error: attribute android:usesPermissionFlags not found.

What version of cordova-android are you using in your project there?

@nikolaof
Copy link
Author

nikolaof commented Jun 8, 2023

I'm using cordova-android in 9.1.0

So I added the <framework src="androidx.annotation:annotation:*"/> line manually in the plugin.xml as mentioned in #978.

Then tried to rebuild and I got this error back:

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not find androidx.annotation:annotation:*.
     Searched in the following locations:
       - https://repo.maven.apache.org/maven2/androidx/annotation/annotation/*/annotation-*.pom
       - https://dl.google.com/dl/android/maven2/androidx/annotation/annotation/*/annotation-*.pom
       - https://jcenter.bintray.com/androidx/annotation/annotation/*/annotation-*.pom
       - file:/home/user/dev/ionic-app-demo/platforms/android/app/libs/annotation-*.jar
       - file:/home/user/dev/ionic-app-demo/platforms/android/app/libs/annotation.jar
     Required by:
         project :app

EDIT:

From a search I did, is seems that all the links it tries to fetch it arel not working. :/ How can this be the case?

EDIT 2:

So after updating into cordova-android 12.0.0, and JDK 11 the app get's compiled.

@peitschie peitschie added this to the 1.7.1 milestone Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants