phonegap 3.0 wants android 17, but I want android 18

我的未来我决定 提交于 2019-11-30 00:30:50
bumerang

Find file android_parser.js in Windows it is undr path:

C:\Users\USER_NAME\AppData\Roaming\npm\node_modules\cordova\src\metadata

change in file android_parse.js

OR if You are makking application from PhoneGap not Cordova:

C:\Users\USER_NAME\AppData\Roaming\npm\node_modules\phonegap\node_modules\cordova\src\metadata\android_parser.js

go to line: 57

if (output.indexOf('android-17') == -1) {

and change it for:

if (output.indexOf('android') == -1) {

This will let You not to wory about future :)

But then You can occur this Error

[Error: An error occured during creation of android sub-project.
]

To fix it You will have to goto this path:

C:\Users\USER_NAME\.cordova\lib\android\cordova\3.1.0\framework\project.properties

And change this line:

target=android-17

To this:

target=android-19

Or whatever is Your Android SDK version

What to do if You want to use Android 2.2 ?

Just simple go to:

Your_Project_Folder/platforms/android/AndroidManifest.xml

And change:

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="19" />

To:

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="19" />

And after that import Your project to Your IDE

Enjoy :)

If anyone gets here using cordova and/or chrome mobile app toolchain. I edited platforms/android/project.properties directly to target=android-19 and it built.

cheers

divoto

Simply open your AndroidManifest.xml file and set minimun and targeted version. In your case 18. Same answer to question Phonegap 3.0 CLI issue android target number in build app.

AndroidManifest.xml file is located in: YOURPROJECT\platforms\android. If you need more assistance ask, will try to help you. Post your AndroidManifest.xml file so I can check.

Go to \cordova\src\metadata\android_parser.js in function check_requirements and change the lines 56,57,66 from 17 to 18. It will then be ok.

Make sure you have the latest version:

  • PhoneGap: sudo npm update -g phonegap
  • Android SDK: depending on how you installed it, if you did it through brew: brew update android-sdk

Then run aandroid, and download the latest API.

Then PhoneGap will use the latest API by default when running phonegap build android.

If you need to update a current project, run inside the project folder:

phonegap platform update android

And now if you run build again, it should use the latest version.

I had installed cordova through npm, therefore to make it work I modified target in ~/.cordova/lib/npm_cache/cordova-android/3.6.3/package/framework/project.properties

I think you have the wrong version of Phonegap, mine says 0.3.0-0.15.0. I think Fil's fix would definitely have made it into the final build, so I think you must be doing something goofy when installing Phonegap. This is what I did:

npm install cordova -g (or I guess in your case it would be Phonegap and not cordova.) This will install cordova (or phonegap) globally so that you can access it anywhere with the 'cordova' command. If you already have it installed try npm update instead of npm install.

Navigate to a workspace location, like C:\workspace.

Type cordova create MyApp which will create a Cordova project at C:\workspace\MyApp. The workspace will have the following folders:

/www/ - where you place all of your HTML and JavaScript

/platforms/ - this will have folders for android, ios, and any other platforms you add. Your stuff from /www/ will get copied over here in the right place for each platform. This is where you would edit platform-specific files, for example, to change the target-sdk, you want to edit /platforms/android/AndroidManifest.xml.

/plugins/ - this is where all of the plugin code will go when you do cordova plugin add {link}. I can't think of any reason why you should ever edit anything in this folder (but there probably are some good ones.)

/merges/ - any files here will get merged with the corresponding files in /www/ and pushed into /platforms/, see the documentation.

After running the create command, you need to add the platforms:

cd MyApp

cordova platform add android -d - the -d gives us debug info

cordova build android - this will build the android app and you will see stuff from /www/ copied over to /platforms/android/assets/www.

One If you are still having issues, did you try what it says in the output, that is, running android from the command line? This will bring up the "Android SDK Manager", make sure that you have the latest version of the SDK installed as well as the latest Android SDK Tools and Android SDK Platform-tools (mine are 22.0.5 and 18.0.1, respectively.)

There may also be issues if you have never created an Android emulator object (use the AVD manager) although that sounds less likely.

C:\Users\USER_NAME.cordova\lib\android\cordova\3.1.0\framework\

should be in bumerang's anser

C:\Users\USER_NAME.cordova\lib\android\cordova\3.1.0\framework\project.properties

PhoneGap Build now supports an option to set the Android SDK version. It is documented here but basically what you need in config.xml is:

  <preference name="android-targetSdkVersion" value="18" />

It will then set the property correctly in AndroidManifest.xml.

Note: This supposedly only works for PhoneGap build, but I am using the Ionic command line tools (on Cordova 5.1.1) and it appears to work fine for me too.

reading from the release notes of version 3.1.0, it says:

  • Incremeting version check for Android 4.3 API Level 18
  • Upgrading project to Android 4.3

Therefore, upgrading to Phonegap 3.1.0 should do the trick.

You are in the wrong place guys

YOU SHOULD TRY THIS: phonegap local build android

this will add the android to your platforms folder...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!