9 Replies Latest reply on Nov 14, 2016 4:01 PM by marks49356571

    Phonegap CLI mistmatch with Android SDK

    marks49356571 Level 1

      Hello.

       

      For some reason the post does not keep the PRE formatting, as seen below, so I had to edit it to default PRE.

      7dc185f888.png

       

      I recently began adventure with app development and since I own an Android device I started with that OS first.

      I want to use backward compatibility to Android 5.1.1 (API 22) and I keep running to this problem.

       

      First things first, PhoneGap CLI is up to date on an up to date Windows 7 SP1 Ultimate.

       

      F:\dir\blank1>phonegap info

      Collecting Data...

       

       

       

      Node version: v6.9.1

       

      Cordova version: 6.1.1

       

      Config.xml file:

       

      <?xml version='1.0' encoding='utf-8'?>

      <widget id="com.phonegap.helloworld" version="1.1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">

          <name>Hello World</name>

          <description>

              A blank PhoneGap app.

          </description>

          <author email="support@phonegap.com" href="http://phonegap.com">

              PhoneGap Team

          </author>

          <content src="index.html" />

          <access origin="*" />

          <engine name="android" spec="~5.1.1" />

      </widget>

       

       

      No Plugins Currently Installed

       

      No Platforms Currently Installed

       

      F:\dir\blank1>phonegap platform list

      Installed platforms:

       

      Available platforms:

        amazon-fireos ~3.6.3 (deprecated)

        android ~5.1.1

        blackberry10 ~3.8.0

        browser ~4.1.0

        firefoxos ~3.6.3

        webos ~3.7.0

        windows ~4.3.1

        wp8 ~3.8.2 (deprecated)

       

      Since 5.1.1 is apparently the lowest available, we'll use it:

       

      F:\dir\blank1>phonegap platform add android@5.1.1

      Adding android project...

       

       

      Creating Cordova project for the Android platform:

       

              Path: platforms\android

              Package: com.phonegap.helloworld

       

              Name: Hello_World

              Activity: MainActivity

              Android target: android-23

       

      Android project created with cordova-android@5.1.1

       

      Notice how it created Android target: android-23 and mind 5.1.1 is API 22.

       

      F:\dir\blank1>phonegap info

      Collecting Data...

       

       

       

      Node version: v6.9.1

       

      Cordova version: 6.1.1

       

      Config.xml file:

       

      <?xml version='1.0' encoding='utf-8'?>

      <widget id="com.phonegap.helloworld" version="1.1.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">

          <name>Hello World</name>

          <description>

              A blank PhoneGap app.

          </description>

          <author email="support@phonegap.com" href="http://phonegap.com">

              PhoneGap Team

          </author>

          <content src="index.html" />

          <access origin="*" />

          <engine name="android" spec="~5.1.1" />

      </widget>

       

       

      No Plugins Currently Installed

       

      Error retrieving Android platform information:

      Android SDK is not set up properly. Make sure that the Android SDK 'tools' and 'platform-tools' directories are in the PATH variable.

       

      Error: cmd: Command failed with exit code 1 Error output:

      'android' is not recognized as an internal or external command,

      operable program or batch file.

       

      That is strange, let's try this:

       

      F:\dir\blank1>phonegap platform list

      Installed platforms:

        android 5.1.1

      Available platforms:

        amazon-fireos ~3.6.3 (deprecated)

        blackberry10 ~3.8.0

        browser ~4.1.0

        firefoxos ~3.6.3

        webos ~3.7.0

        windows ~4.3.1

        wp8 ~3.8.2 (deprecated)

       

      F:\dir\blank1>phonegap build android --debug

      [phonegap] executing 'cordova build android --debug ' ...

      Error: Please install Android target: "android-23".

       

      Hint: Open the SDK manager by running: "C:\Users\me\AppData\Local\Android\android-sdk\tools\android.bat"

      You will require:

      1. "SDK Platform" for android-23

      2. "Android SDK Platform-tools (latest)

      3. "Android SDK Build-tools" (latest)

       

      That's the problem, 5.1.1 (in fact API 22) requires API 23 which is Android 6, and I can't get it to build.

      This is my SDK configuration:

       

      Untitled.jpg

       

      When I change target=android-23 to target=android-22 in:

      blank1\platforms\android\project.properties

      blank1\platforms\android\CordovaLib\project.properties

      and edit blank1\platforms\android\AndroidManifest.xml accordingly,

      I get a flood of Java compiler errors about missing things unknown symbols.

       

      Why is Phonegap dioing this? I don't get it, please tell me what I'm doing wrong.

       

      Thanks in advance for any help,

      Mark.

        • 1. Re: Phonegap CLI mistmatch with Android SDK
          simon.macdonald Adobe Employee

          Mark you should always use the highest available, not the lowest. cordova-android 6.1.0 is out and I suggest you use that one.

          • 2. Re: Phonegap CLI mistmatch with Android SDK
            marks49356571 Level 1

            simon.macdonald I want to keep my apps compatible with older Androids, initially I wanted my apps to work even on Android 4.3 but Phonegap doesn't go back before 5.1.1.

             

            If I understand correctly as long as Phonegap supports 5.1.1 I can use SDK 5.1.1 to create apps compatible with 5.1.1 phones.

            • 3. Re: Phonegap CLI mistmatch with Android SDK
              simon.macdonald Adobe Employee

              You are mis-understanding the version numbers. cordova-android 6.1.0 sets the target sdk to 24 (Android 7.0) and the minimum SDK is set to 16 (Android 4.1). You always want to use the latest cordova-android version you can to support the latest Android OS releases. Let us worry about backward compatibility.

              • 4. Re: Phonegap CLI mistmatch with Android SDK
                marks49356571 Level 1

                You are completely right to say I misunderstand version numbers, I was just introduced to nodejs, npm, phonegap, cordova and android SDK and I'm pretty confused, it's a lot to take on at once.

                 

                OK, so here's what I did:

                 

                F:\dir\blank1>phonegap platform update android@6.1

                 

                F:\dir\blank1>phonegap platform list

                Installed platforms:

                  android 6.1.0

                Available platforms:

                  amazon-fireos ~3.6.3 (deprecated)

                  blackberry10 ~3.8.0

                  browser ~4.1.0

                  firefoxos ~3.6.3

                  webos ~3.7.0

                  windows ~4.3.1

                  wp8 ~3.8.2 (deprecated)

                 

                Installed SDK API 24

                Shortened the below output:

                 

                F:\dir\blank1>phonegap build --debug

                [phonegap] executing 'cordova build --debug ' ...

                 

                FAILURE: Build failed with an exception.

                > You have not accepted the license agreements of the following SDK components:

                [Android SDK Platform 25].

                 

                Installed SDK API 25

                 

                ac630f41fe.png

                 

                F:\dir\blank1>phonegap build --debug

                [phonegap] executing 'cordova build --debug ' ...

                [phonegap] completed 'cordova build --debug --no-telemetry'

                 

                All good, now I have blank1\platforms\android\build\outputs\apk\android-debug.apk built on SDK platform for Android 7.0/7.1, how can I tell if the app will run on Android 4.3?

                • 5. Re: Phonegap CLI mistmatch with Android SDK
                  simon.macdonald Adobe Employee

                  If you look at blank1\platforms\android\AndroidManifest.xml it will have a line like:

                   

                  <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="24" />

                   

                  the minSdkVersion will be the lowest level of Android the app can run on. You can look them up here:

                   

                  Codenames, Tags, and Build Numbers | Android Open Source Project

                  • 6. Re: Phonegap CLI mistmatch with Android SDK
                    marks49356571 Level 1

                    Firstly thank you simon.macdonald for taking your time to answer my thread.

                     

                    Yes I did see that line in the blank1\platforms\android\AndroidManifest.xml file before. Are you saying it's enough to change those values before I build the app, and that's it? Earlier I said I made relevant edits to:

                    blank1\platforms\android\project.properties

                    blank1\platforms\android\CordovaLib\project.properties

                    and edit blank1\platforms\android\AndroidManifest.xml accordingly

                    ...and it did not work, it kept throwing errors or exceptions and required higher level SDK. You never commented on that.

                    It does not make much sense that a project set to target 22 requires API 25 and will work just fine on Android 5.1.1 (API 22).

                     

                    It is not my intention to sound rudely, but from an Adobe employee I'd expect a bit more than two-liners that don't tell me where I was wrong.

                    I don't mind being told I'm wrong if I'm also told how can I stop being wrong, I came here to learn.

                    Please don't take this as a rant, all I'm asking is that before you hit "Add reply", make sure you answered my issues.

                     

                    Thanks!

                    • 7. Re: Phonegap CLI mistmatch with Android SDK
                      simon.macdonald Adobe Employee

                      Mark, do not touch the files in the platforms directory of any PhoneGap/Cordova project. The files in platforms are build artifacts. You create your PhoneGap app by editing the config.xml, the contents of the www directory and adding plugins. Anything you edit under platforms will be over-written the next time you build your app.

                       

                      Your original problem was you equated using cordova-android 5.1.1 as only supporting Android 5.1.1 or higher. As I mentioned that was an incorrect assumption.

                       

                      You then upgraded your SDK and asked how could you tell if the app you built would work on Android 4.3. To which I replied, look at the uses-sdk tag, check the number indicated for minSdkValue and look it up at the link provided. So as long as your minimum SDK value is 18 or lower it will run on Android 4.3.

                       

                      I know you've been thrown into the deep end and are picking up a bunch of new technologies right now but I felt that I did answer your question. Sorry I was not more clear.

                      • 8. Re: Phonegap CLI mistmatch with Android SDK
                        marks49356571 Level 1

                        Like I said it was not a rant, though I felt as if your answers were not on point, but close to it, still I appreciate your time.

                         

                        So now that you said those files inside platforms subdirectories are overwritten on build, I understand why it's pointless to edit them, thanks.

                         

                        Yes, you mentioned it was incorrect assumption, though you said things like "let us worry about backward compatibility" and I had to be sure how it works exactly, I should have been more specific.

                         

                        You indeed told me about <uses-sdk/> tag but the behaviour of the SDK config versus Phonegap, that I explained earlier as quite problematic and unknown to me, did not initially confirm it'd be so simple, therefore your answer seemed to have belittled the important issue among all issues. But again, I could have asked more specifically.

                         

                        Now I'll assume the <uses-sdk/> tag uses target SDK and that particular SDK is asked for compatibility down to older API specified, or something along those lines, correct me if I'm wrong please.

                         

                        Mark!

                        • 9. Re: Phonegap CLI mistmatch with Android SDK
                          marks49356571 Level 1

                          I also assume that I should worry myself about differences in Android APIs when it comes down to e.g. on-board device support, and when I choose to allow API 18 I need to check myself if version 18 support my requirements.

                           

                          Thanks!