apla / me.apla.cordova.app-preferences

App preferences plugin for cordova
Apache License 2.0
201 stars 210 forks source link

Android build fails without app-settings.json #87

Open Manduro opened 8 years ago

Manduro commented 8 years ago

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

apla commented 7 years ago

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

uloco commented 7 years ago

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).

apla commented 7 years ago

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