capacitor-community / native-audio

MIT License
109 stars 66 forks source link

AppCompatActivity error after updating to Capacitor 3 #27

Closed andrewl94 closed 3 years ago

andrewl94 commented 3 years ago

Describe the bug

After updating to Capacitor 3 I've been receiving the error bellow. I already used Refactor > Migrate to AndroidX. Before the refactor other plugins were giving similar error, but probably solved by the refactor. I'm really lost, probably I need to change some reference somewhere, but I had no luck researching that for now.


{{project_dir}}\app\src-capacitor\node_modules\@capacitor-community\native-audio\android\src\main\java\com\getcapacitor\community\audio\NativeAudio.java:54: error: cannot access AppCompatActivity .getActivity() ^ class file for androidx.appcompat.app.AppCompatActivity not found


My gradle variables:

minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
androidxActivityVersion = '1.2.0'
androidxAppCompatVersion = '1.2.0'
androidxCoordinatorLayoutVersion = '1.1.0'
androidxCoreVersion = '1.3.2'
androidxFragmentVersion = '1.3.0'
junitVersion = '4.13.1'
androidxJunitVersion = '1.1.2'
androidxEspressoCoreVersion = '3.3.0'
cordovaAndroidVersion = '7.0.0'

To Reproduce Steps to reproduce the behavior:

  1. Update Capacitor to 3 Expected behavior

Screenshots

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

danielehrhardt commented 3 years ago

Something new here?

andrewl94 commented 3 years ago

I had to go back to using Capacitor 2.4 IMO the Capacitor 3 are not worth the trouble for now.

wmtkc commented 3 years ago

I was able to get the build to work by adding these lines to the /android/build.gradle file

ext {
    junitVersion =  project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.12'
// Add here
+   androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.2.0'
    androidxJunitVersion =  project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.1'
    androidxEspressoCoreVersion =  project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.2.0'
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation project(':capacitor-android')
// And here
+   implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
    testImplementation "junit:junit:$junitVersion"
    androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
    androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
}

But the plugin code itself doesn't seem to be functioning after a successful build. Calls to play() throw the following error on both iOS and Android.

Uncaught Error: Method not implemented.

Howler.js seems to do the job in the meantime, if you need to be on Capacitor 3.

bazuka5801 commented 3 years ago

@andrewl94 If your issue connected with plugin, please send message here.