I have an Ionic project I'm working with that is having trouble building to Android. I inherited this project, so that's why I'm not 100% familiar with Fastlane and how it's building the java files. Additionally, I'm on WSL2 and using sdkmanager with the following installed packages:
Installed packages:=====================] 100% Fetch remote repository...
Path | Version | Description | Location
------- | ------- | ------- | -------
build-tools;29.0.2 | 29.0.2 | Android SDK Build-Tools 29.0.2 | build-tools/29.0.2
emulator | 30.8.4 | Android Emulator | emulator
patcher;v4 | 1 | SDK Patch Applier v4 | patcher/v4
platform-tools | 31.0.3 | Android SDK Platform-Tools | platform-tools
platforms;android-29 | 5 | Android SDK Platform 29 | platforms/android-29
When I run bundle exec fastlane android build
it does a whole lot of magic, but in the end, results in the following error:
> Task :app:compileReleaseJavaWithJavac FAILED
/home/zonyx/git/gitlab/studio/platforms/android/app/src/main/java/org/apache/cordova/camera/CameraLauncher.java:42: error: package android.support.v4.content does not exist
import android.support.v4.content.FileProvider;
^
/home/zonyx/git/gitlab/studio/platforms/android/app/src/main/java/org/apache/cordova/camera/FileProvider.java:21: error: package android.support.v4.content does not exist
public class FileProvider extends android.support.v4.content.FileProvider {}
^
/home/zonyx/git/gitlab/studio/platforms/android/app/src/main/java/org/apache/cordova/camera/CameraLauncher.java:297: error: cannot find symbol
this.imageUri = FileProvider.getUriForFile(cordova.getActivity(),
^
symbol: method getUriForFile(Activity,String,File)
location: class FileProvider
/home/zonyx/git/gitlab/studio/platforms/android/app/src/main/java/org/apache/cordova/camera/CameraLauncher.java:824: error: cannot find symbol
Uri tmpFile = FileProvider.getUriForFile(cordova.getActivity(),
^
symbol: method getUriForFile(Activity,String,File)
location: class FileProvider
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.
4 errors
I've seen some thoughts about newer SDK versions using androidx.core.content.FileProvider
instead of android.support.v4.content.FileProvider
. Since the entire Android portion is built / generated automatically, I obviously can't change the java file because it will just get overwritten.
Here's a line of the Fastfile that may be helpful:
desc 'Compile a new build for Android'
lane :build do |options|
Dir.chdir('..') do
before_build(options)
ionic_build
sh("ionic cordova build android --device --release --aot false --environment prod --output-hashing all \
--sourcemaps false --extract-css true --named-chunks false --build-optimizer true --minifyjs=true \
--minifycss=true --optimizejs=true")
deeplinks(action: 'uninstall')
end
end
CodePudding user response:
cordova-plugin-androidx-adapter will migrate older libraries to use AndroidX Support Libraries automatically. I believe this is needed when you target Android 10 or higher, which is when the switch was made. Once all of your plugins support AndroidX, you can remove the adapter plugin.