Skip to main content

Creating a HelloWorld Android App for Amazon Fire Phone

I've tried creating a sample project for Amazon Fire Phone and found a few issues and workarounds. I thought it might be helpful to share them here. It might be useful to Android developers getting started with Amazon Fire Phone programming.

I've followed steps on setting up development environment provided by the Amazon site. Once I've got an Amazon Fire Phone SDK Addon installed, I've created a sample app in Android Studio v1.3.2. In this example, I am using buildToolsVersion "23.0.0"

Here are the steps for creating a new project:

Android Studio v1.3.2.
- File > New > New Project
   - Application Name: HelloWorld
   - Company Domain: practice.mdzyuba.com
   - Next
- Check on Phone and Tablet box
   - Select Minimum SDK: API 17: Android 4.2 (Jelly Bean)
   - Next
- Select a Blank Activity to be added
   - Next
- Finish

The projects has failed to compile and I've got a few errors:

/Users/mykola/Code/practice/android_practice/amazon/HelloWorld/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/23.0.0/res/values-v23/values-v23.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.

It looks like an Android Studio issue https://code.google.com/p/android/issues/detail?id=183478.

A workaround is to change or comment out the com.android.support:appcompat dependency in build.gradle:

app/build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0"

    defaultConfig {
        applicationId "com.mdzyuba.practice.sample1"
        minSdkVersion 17
        targetSdkVersion 17
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
//    compile 'com.android.support:appcompat-v7:23.0.0'
    compile "com.android.support:appcompat-v7:22.+"
}

After that, the project build is successful.

Next, I change the gradle version as suggested by the Amazon instructions:

build.gradle:
   dependencies {
//        classpath 'com.android.tools.build:gradle:1.3.0'
        classpath 'com.amazon.device.tools.build:gradle:1.1.+'

Now, I've got an error: 

Error:Gradle 2.4 requires Android Gradle plugin 1.2.0 (or newer)  but project is using version 1.1.3.
Please use Android Gradle plugin 1.2.0 or newer.
Fix plugin version and sync project

I've modified Project Structure > Project > Gradle version: 2.2.1. I've got this version from the Amazon examples. After that, I've got a few more errors

.../Sample1/app/build/intermediates/exploded-aar/com.android.support/appcompat-v7/22.2.1/res/values-v21/values-v21.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material'.

So, I've decided to comment out com.android.support:appcompat dependency completely:

app/build.gradle:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
//    compile 'com.android.support:appcompat-v7:23.0.0'
//    compile "com.android.support:appcompat-v7:22.+"
}

Now, I am getting a style error:

.../Sample1/app/src/main/res/values/styles.xml
Error:(2) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.

Since there is no appcompat dependency, I've modified AppTheme in styles.xml to have a theme provided by the Android SDK:
   
Next error:
 
.../Sample1/app/src/main/res/menu/menu_main.xml
Error:(5) No resource identifier found for attribute 'showAsAction' in package 'com.mdzyuba.practice.sample1'

I just removed app:showAsAction="never"  attribute from the menu item element:


< item android:id="@+id/action_settings" android:title="@string/action_settings"

        android:orderInCategory="100" >


Next, I've got following errors:
.../Sample1/app/src/main/java/com/mdzyuba/practice/sample1/MainActivity.java
Error:(3, 30) error: package android.support.v7.app does not exist
Error:(8, 35) error: cannot find symbol class AppCompatActivity
Error:(10, 5) error: method does not override or implement a method from a supertype
Error:(12, 9) error: cannot find symbol variable super
Error:(13, 9) error: cannot find symbol method setContentView(int)
Error:(16, 5) error: method does not override or implement a method from a supertype
Error:(19, 9) error: cannot find symbol method getMenuInflater()

I've removed a dependency on the support lib in MainActivity class:

// import android.support.v7.app.AppCompatActivity;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends Activity {

Finally, good news: BUILD SUCCESSFUL :)

Running the app:


Hope it might be helpful and save time to anybody else who is creating apps for Amazon Phone with Android Studio.

Comments

Popular posts from this blog

MySQL macport install on Mac OS X Tiger

I have installed mysql5 macport on the MacBookPro laptop running OS X Tiger 10.4. There are a few steps that needs to be done once the port is installed. These steps are not documented (see Ticket #12694 on macports.org). So, after reading a few blogs and analyzing mysql startup error messages, I figured out what needs to be done in order to get it running. That info might be useful to others, so I’ve decided to publish the solution here. First of all, we need to create the initial database database $ sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql Here is the output of the command: $ sudo ./mysql_install_db --user=mysql Installing MySQL system tables... 071118 0:06:29 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive OK Filling help tables... 071118 0:06:29 [Warning] Setting lower_case_table_names=2 because file system for /opt/local/var/db/mysql5/ is case insensitive OK To start mysqld at boot time you hav...

cucumber-jvm and Android Studio

During this Winter holidays, I've been exploring a Behavior Driven Development and experimented with a couple of testing frameworks: Calabash and cucumber-jvm . In this post, I would like to describe setting up cucumber-jvm for Android Studio projects. I've extended cucumber-jvm examples with a version for Android Studio. Here is a copy in my github branch: https://github.com/mdzyuba/cucumber-jvm/tree/add_android_studio_example/examples/android/android-studio/Cukeulator . In addition to the example code, here is some details on how it was created. Dependencies The cucumber-jvm requires several libraries to be added to a project:  https://github.com/cucumber/cucumber-jvm/tree/master/android I've found it's easier to add those dependencies with the Android Studio project setup dialog because it takes care of the jar versions for you. File > Project Structure > Modules > app > Dependencies > + > Library dependency   > type "cuc...

Deploying BlazeDS to Weblogic 10.0

The BlazeDS is a free and open source J2EE application that provides data services to Adobe Flex and AIR applications. I’ve deployed it to Weblogic 10.0 server. I thought somebody else would be interested to do the same. Here is how. In case you need to install Weblogic 10.0, the developers copy is available for free at http://commerce.bea.com/products/weblogicplatform/weblogic_prod_fam.jsp . I have it installed on my Windows XP at D:\bea10 folder. I have created a new domain for my BlazeDS applications. It is easy to do, see http://edocs.bea.com/common/docs100/confgwiz/index.html for details. In my case, the domain name is blazeds and it is located in D:\bea10\user_projects\domains\blazeds folder on my computer. The domain name and the folders names can be difference, I just mentioned them so it is easier to follow the examples.. Once the Weblogic server is installed and a domain is ready, the BlazeDS applications can be deployed. A copy of BlazeDS is available...