me.apla.cordova.app-preferences icon indicating copy to clipboard operation
me.apla.cordova.app-preferences copied to clipboard

Android build fails without app-settings.json

Open Manduro opened this issue 8 years ago • 3 comments

When I remove app-settings.json (as I don't need the interface), building on Android fails:

platforms/android/src/me/apla/cordova/AppPreferencesActivity.java:27:
error: cannot find symbol
addPreferencesFromResource(R.xml.apppreferences);

I found that it does work when I use an app-settings.json with an empty array in it ([]). It seems to have to do with the fact that it can't find the res/xml/apppreferences.xml file. Maybe the plugin should create that file even if there is no app-settings.json.

PS: seems related to #81

Manduro avatar Apr 04 '16 13:04 Manduro

Seems like something is wrong with your setup:

$ ls -la app-settings.json 
-rw-r--r--  1 apla  staff  447 Jul 10 22:16 app-settings.json
$ cordova build android --simulator
will push strings array {"name":"lang","titles":["English (US)","English (UK)"],"values":["en-us","en-gb"]}
android preferences file was successfully generated
ANDROID_HOME=/Applications/devel/android
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home
…
BUILD SUCCESSFUL

Total time: 4.253 secs
Built the following apk(s): 
    platforms/android/build/outputs/apk/android-debug.apk
$ rm app-settings.json 
$ cordova build android --simulator
app-settings.json not found: skipping build
ANDROID_HOME=/Applications/devel/android
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home
…
BUILD SUCCESSFUL

Total time: 1.877 secs
Built the following apk(s): 
    platforms/android/build/outputs/apk/android-debug.apk

Try to install latest version

apla avatar Jul 10 '16 20:07 apla

I got the same error pointed above. It actually works, if you build once with a app-settings.json file and then remove the file and build after-wards. Try adding the plugin and removing the settings file directly after that and building afterwards. This fails for me. I have a after_plugin_add hook in my config.xml, which removes the app-settings.json file because I have no other control over the build process. This seems to work on our build server (Cordova 5.4.1) but not on my local machine (Cordova 6.2.0).

uloco avatar Jul 22 '16 14:07 uloco

Seems like AppPreferencesActivity.java not removed somehow. Very strange.

apla avatar Jul 27 '16 12:07 apla