Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Updated project to better support Android Studio #6

Merged
merged 3 commits into from
Apr 28, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 0 additions & 55 deletions AndroidManifest.xml

This file was deleted.

85 changes: 13 additions & 72 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,36 @@ A fast way to get started with the [Google Maps Android API v2](http://developer

#### Current version of library dependencies:

* Google Play Services, revision 7
* Android Support Library, revision 13
* Google Play Services Maps 8.4.0

# TOC

* [Requirements](#requirements)
* [Check out the project](#check-out-the-project)
* [Eclipse](#eclipse)
* [Download Eclipse](#download-eclipse)
* [Import the project to your workspace](#import-the-project-to-your-workspace)
* [Android Studio](#android-studio)
* [Download Android Studio](#download-android-studio)
* [Open the project](#open-the-project)
* [Add your API key](#add-your-api-key)
* [Run the app](#run-the-app)
* [Troubleshooting](#troubleshooting)
* [IntelliJ](#intellij)
* [Download IntelliJ](#download-intellij)
* [Import the project](#import-the-project)
* [Add your API key](#add-your-api-key-1)
* [Run the app](#run-the-app-1)
* [Troubleshooting](#troubleshooting-1)

# Requirements

Java Development Kit (JDK) [Download](http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html)
Java Development Kit (JDK) [Download](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)

Android SDK [Download](http://developer.android.com/sdk/index.html)

# Eclipse
# Android Studio

## Download Eclipse
Eclipse is packaged with the [Android Developer Tools bundle](http://developer.android.com/sdk/index.html)
## Download Android Studio
Download Android Studio (http://developer.android.com/sdk/index.html)

## Import the project to your workspace
1. Choose File> Import...
2. Choose Android > Existing Android Code Into Workspace
3. Navigate to the checked out project
4. You should see two projects - "hellomap" and "google-play-services_lib".
5. Ensure both are selected
6. Press "Finish"
## Open the project
1. On the welcome screen, select "Open an existing Android Studio project" or if you have a project open, choose "File->Open...""
2. Navigate to the checked out project
3. Press "Ok"

## Add your API key

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section doesn't look right for Android Studio. in the default 'Android' view, the manifest is under 'Application -> manifests'

1. Navigate to AndroidManifest.xml, under the "hellomap" project.
1. Navigate to the AndroidManifest.xml file
2. Click the "AndroidManifest.xml" tab, next to "Instrumentation", to see the XML view.
Copy link
Contributor

@markmcd markmcd Apr 22, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line still true?

(originally I meant this in terms of the "instrumentation" tab, but it looks like you've added a custom XML file with the key, so I think this whole block needs an update)

3. Replace "your_api_key" with an API key generated using [these instructions](https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key)

Expand All @@ -53,54 +42,6 @@ Eclipse is packaged with the [Android Developer Tools bundle](http://developer.a

## Troubleshooting
### I see a grey map

Follow the instructions under "Add your API key" and try again.

### I see the Android starter screen
1. Choose Window>Close All Perspectives
2. Choose Window>Open Perspective>Other...
3. Choose Java

# IntelliJ
## Download IntelliJ
http://www.jetbrains.com/idea/download/
Choose the "Community Edition"

## Import the project
1. In the start up screen, choose "Open project"
2. Select the checked out project, press OK

## Add your API key
1. Navigate to the AndroidManifest.xml file
2. Replace "your_api_key" with an API key generated using [these instructions](https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key)

## Run the app
1. Ensure your phone is in plugged in, developer mode enabled and screen unlocked
2. Choose Run>Edit Configurations...
3. Press the + button
4. Click "Android Application"
5. Edit the name
6. Choose "hellomap" as the Module
7. Choose "USB Device" as your Target Device
8. Press OK
9. Press the green play button next to the name you specified. This will build the app, install it on the device and run it.

## Troubleshooting
### "Please specify Android SDK"
1. Click "New..."
2. Choose "Android SDK"
3. Navigate to the Android SDK's "sdk" directory, press "Choose"

### "No Java SDK of appropriate version found"
1. Click "New..."
2. Choose "JDK"
3. Navigate to the JDK's home directory. For OS X, this is at `/Library/Java/JavaVirtualMachines/jdk.../Contents/Home`
4. Press "Choose"
5. If you are prompted with "Set up created SDK on project?", press No.
6. Follow the instructions above
7. If you are prompted with "Set up created SDK on project?", press Yes.

### I see a grey map
Follow the instructions under "Add your API key" and try again.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps add a line here suggesting that the developer should also keep an eye on the logcat output, as the API will often provide extra information there, e.g. if the cert/key aren't set up correctly.



Expand Down
25 changes: 25 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "com.example.hellomap"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-project.txt')
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-maps:8.4.0'
}
15 changes: 15 additions & 0 deletions app/src/debug/res/values/google_maps_api.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.

To get one, follow this link, follow the directions and press "Create" at the end:

https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID

Follow the directions here:
https://developers.google.com/maps/documentation/android/start#get-key

Once you have your key, replace the "google_maps_key" string in this file.
-->
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">your_api_key</string>
</resources>
34 changes: 34 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- TODO: Replace "com.example.hellomap" with your desired package name -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.hellomap"
android:versionCode="1"
android:versionName="1.0">

<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher">

<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key"/>

<activity
android:name="MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>

</manifest>
File renamed without changes.
33 changes: 11 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
mavenCentral()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
}
}

apply plugin: 'android'
classpath 'com.android.tools.build:gradle:2.0.0'

dependencies {
compile 'com.google.android.gms:play-services:3.1.36'
compile 'com.android.support:support-v4:13.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

android {
compileSdkVersion 17

buildToolsVersion "17.0.0"

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
}
allprojects {
repositories {
jcenter()
}
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Apr 10 15:27:10 PDT 2013
#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
10 changes: 3 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ case "`uname`" in
;;
esac

# For Cygwin, ensure paths are in UNIX format before anything is touched.
if $cygwin ; then
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
fi

# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
Expand All @@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
cd "$SAVED" >/dev/null

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

Expand Down Expand Up @@ -114,6 +109,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`

# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ':app'