google / nogotofail

An on-path blackbox network traffic security testing tool
Apache License 2.0
2.94k stars 418 forks source link

Migrate Android client project to Android Studio #91

Closed mkenne11 closed 9 years ago

mkenne11 commented 9 years ago

The Eclipse Android client project was migrated to an Android Studio project.

When the project is opened in Android Studio the "Gradle Sync" dialog will appear stating: Gradle settings for this project are not configured yet.

Selecting the "OK" option will build the Gradle wrapper.

chadbrubaker commented 9 years ago

Alex can you take a look?

Are the renames needed? We need to make sure that they don't cause issues with the bazel build.

mkenne11 commented 9 years ago

No worries. TBH I only tried building the client from inside the Android Studio IDE.

I experimented with the project files and found the latest committed project files build for me from the command line using gradlew (./gradlew).

Unfortunately I had to include the /gradle/wrapper directory. I also added the local.properties to point to the location of the Android SDK - however I looks like you can exclude this file if you ANDROID_HOME environment variable: http://stackoverflow.com/questions/19794200/gradle-android-and-the-android-home-sdk-location

I don't fully understand gradle and building from the command line yet. I'll explore further to see if I can minimize the project files further.

BTW. Hopefully I set the paths correctly in the Bazel BUILD file to where they reside in the Android Studio structure.

klyubin commented 9 years ago

Just a couple of minor issues:

  1. There's an issue in BUILD file -- see comment there.
  2. Please remove unnecessary entries from .gitignore. There's no need to have the following ones: .apk, .ap_ (these are inside bin/ which is already excluded), .dex, .class, proguard/ (we no longer use Eclipse and this project wasn't proguarded anyway), *.log. Please also remove all commented out entries, such as gradle, gradlew, local.properties.
  3. Please exclude local.properties from version control because the SDK path in the file is specific to each developer's environment. Please instead add local.properties to .gitignore.
mkenne11 commented 9 years ago

I made the updates requested to the Android client BUILD and .gitignore files.

Also, I found I could exclude gradle wrapper artifacts (gradlew & gradlew.bat, and /gradle/wrapper folder). See latest commit.

The comment below is the procedure I followed on my local (Ubuntu) machine to do a gradle build from the command line. Hopefully it works for you too :)

mkenne11 commented 9 years ago

Procedure to build ngtf Android Client using Gradle

Pre-requisites:

Steps

  1. Open a terminal session and start in the Android client project directory: nogotofail/clients/android
  2. Create the Gradle Wrapper using the command:

    gradle wrapper

    The .gradle & gradle directories, and gradlew & gradlew.bat files should be created.

  3. Assign read-write-executable permissions to the .gradle/ directory
  4. Build the project. To test I created a debug (unsigned) build using the command:

    ./gradlew assembleDebug

The app/build directory should be created containing the compiled apk and other build files.

klyubin commented 9 years ago

This looks good. Would you please squash all these commits into one and re-upload (e.g., git push --force) or create separate pull request? The current individual commits will look weird in the commit log: they make breaking changes. Thanks in advance.

mkenne11 commented 9 years ago

No worries. I used the current PR - I squashed the 3 commits into one and did a forced update. Let me know if any additional changes are needed.

I'll also submit a PR soon after I have migrated the Android test client to Android Studio.

klyubin commented 9 years ago

Thank you very much!