Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Pages: [1] 2 3  All

Author Topic: Android, how to set up project?  (Read 29989 times)

0 Members and 1 Guest are viewing this topic.

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Android, how to set up project?
« on: October 23, 2015, 06:52:11 AM »

Hello I followed the instructions here: http://res.dead-code.org/doku.php/wmelite:building

But they do not seem to tell me how to set up the Android project itself. Do I use Eclipse or Android Studio? I tried loading it into Android studio and it doesnt seem to want to take the Android source. Any help? Thanks.
Logged

HCDaniel

  • Regular poster
  • ***
  • Karma: 8
  • Offline Offline
  • Posts: 168
    • View Profile
Re: Android, how to set up project?
« Reply #1 on: October 24, 2015, 10:52:15 AM »

Hello I followed the instructions here: http://res.dead-code.org/doku.php/wmelite:building

But they do not seem to tell me how to set up the Android project itself. Do I use Eclipse or Android Studio? I tried loading it into Android studio and it doesnt seem to want to take the Android source. Any help? Thanks.

I don't use Android Studio to build, but you might try to generate a project if you like. There should be a wizard that helps you with that. I use the standalone tools to create a project with sth. like that

Code: [Select]
android update project --path=.

and to build I then use ant:

Code: [Select]
ant clean debug

should build a version with your debug developer key, and you can install it to an attached device (or emulator) with

Code: [Select]
ant installd

If you've never worked a lot on the command line, trying to generate an Android Studio project might be the better way to go. I'm not sure you would want to use Eclipse, as this is no longer supported by Google for quite a while now (I wonder whether you'll still find an Eclipse based Android IDE at all).
Logged

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: Android, how to set up project?
« Reply #2 on: October 24, 2015, 12:00:53 PM »

Thanks for the reply. I didnt see any Wizard for Android Studio, I just created a new project and dragged and dropped the WME files in the project files. Changes the Manafest file, etc, but it did not work. So I would use the command line from files already in the WME Android source, or get it form somewhere else? Sorry for the questions, as I am new to Android development.
Logged

HCDaniel

  • Regular poster
  • ***
  • Karma: 8
  • Offline Offline
  • Posts: 168
    • View Profile
Re: Android, how to set up project?
« Reply #3 on: October 24, 2015, 01:27:19 PM »

You just need the "android" tool from the SDK, and probably you need to install "ant" separately. If you already downloaded Android Studio, the SDK is already installed (somewhere).
Logged

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: Android, how to set up project?
« Reply #4 on: October 25, 2015, 01:13:42 AM »

Hi again. I am using Ant, and the commands listed in your message. After doing debug, it mentions the build.XML file, but nothing is generating a .apk file. Am I missing something? I am really stupid when it comes to the command line and Android development, so maybe you can explain a very beginners guide? I will be happy to donate to you some money if it works.
Logged

HCDaniel

  • Regular poster
  • ***
  • Karma: 8
  • Offline Offline
  • Posts: 168
    • View Profile
Re: Android, how to set up project?
« Reply #5 on: October 25, 2015, 10:25:18 AM »

This should work for you with a recent wmelite checkout:

Code: [Select]
hg status .

in wmelite/android shows that all my local modifications are the native libraries added:

Code: [Select]
daniel@androiduser-Aspire-V3-772:~/wmelite/android$ hg status .
? libs/AdBuddiz-2.4.4.jar
? libs/armeabi-v7a/libSDL2.so
? libs/armeabi-v7a/libbass.so
? libs/armeabi-v7a/libfreeimage.so
? libs/armeabi-v7a/libgnustl_shared.so
? libs/armeabi-v7a/libmain.so
? libs/armeabi/libSDL2.so
? libs/armeabi/libbass.so
? libs/armeabi/libfreeimage.so
? libs/armeabi/libgnustl_shared.so
? libs/armeabi/libmain.so
? libs/x86/libSDL2.so
? libs/x86/libbass.so
? libs/x86/libfreeimage.so
? libs/x86/libgnustl_shared.so
? libs/x86/libmain.so

At first a file called "local.properties" is required:

Code: [Select]
daniel@androiduser-Aspire-V3-772:~/wmelite/android$ android update project --path .
Updated local.properties
Updated file ./proguard-project.txt

Now all should be set for a debug build with ant:

Code: [Select]
daniel@androiduser-Aspire-V3-772:~/wmelite/android$ ant clean debug
Buildfile: /home/daniel/wmelite/android/build.xml

-check-env:
 [checkenv] Android SDK Tools Revision 24.4.0
 [checkenv] Installed at /opt/android/android-sdk-linux

-setup:
     [echo] Project Name: SDLActivity
  [gettype] Project Type: Application

-pre-clean:

clean:
[getlibpath] Library dependencies:
[getlibpath] No Libraries
   [subant] No sub-builds to iterate on

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 24.4.0
 [checkenv] Installed at /opt/android/android-sdk-linux

-setup:
     [echo] Project Name: SDLActivity
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 19.1.0
     [echo] Resolving Build Target for SDLActivity...
[gettarget] Project Target:   Android 4.0.3
[gettarget] API level:        15
     [echo] ----------
     [echo] Creating output directories if needed...
    [mkdir] Created dir: /home/daniel/wmelite/android/bin
    [mkdir] Created dir: /home/daniel/wmelite/android/bin/res
    [mkdir] Created dir: /home/daniel/wmelite/android/bin/rsObj
    [mkdir] Created dir: /home/daniel/wmelite/android/bin/rsLibs
    [mkdir] Created dir: /home/daniel/wmelite/android/gen
    [mkdir] Created dir: /home/daniel/wmelite/android/bin/classes
    [mkdir] Created dir: /home/daniel/wmelite/android/bin/dexedLibs
     [echo] ----------
     [echo] Resolving Dependencies for SDLActivity...
[dependency] Ordered libraries:
[dependency]
[dependency] ------------------
[dependency] API<=15: Adding annotations.jar to the classpath.
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] Handling aidl files...
     [aidl] No AIDL files to compile.
     [echo] ----------
     [echo] Handling RenderScript files...
     [echo] ----------
     [echo] Handling Resources...
     [aapt] Generating resource IDs...
     [echo] ----------
     [echo] Handling BuildConfig class...
[buildconfig] Generating BuildConfig class.

-pre-compile:

-compile:
    [javac] Compiling 5 source files to /home/daniel/wmelite/android/bin/classes
    [javac] Note: /home/daniel/wmelite/android/src/org/libsdl/app/SDLActivity.java uses or overrides a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.

-post-compile:

-obfuscate:

-dex:
      [dex] input: /home/daniel/wmelite/android/bin/classes
      [dex] input: /opt/android/android-sdk-linux/tools/support/annotations.jar
      [dex] input: /home/daniel/wmelite/android/libs/AdBuddiz-2.4.4.jar
      [dex] Pre-Dexing /opt/android/android-sdk-linux/tools/support/annotations.jar -> annotations-2da80f7fba88282179c6a4e41fc58588.jar
      [dex] Pre-Dexing /home/daniel/wmelite/android/libs/AdBuddiz-2.4.4.jar -> AdBuddiz-2.4.4-be83e5349564857c26edd123b8ec492c.jar
      [dex] Converting compiled files and external libraries into /home/daniel/wmelite/android/bin/classes.dex...
       [dx] Merged dex A (32 defs/39,1KiB) with dex B (2 defs/1,1KiB). Result is 34 defs/46,1KiB. Took 0,1s
       [dx] Merged dex A (34 defs/46,1KiB) with dex B (75 defs/95,4KiB). Result is 109 defs/160,9KiB. Took 0,1s

-crunch:
   [crunch] Crunching PNG Files in source dir: /home/daniel/wmelite/android/res
   [crunch] To destination dir: /home/daniel/wmelite/android/bin/res
   [crunch] Processing image to cache: /home/daniel/wmelite/android/res/drawable-hdpi/ic_launcher.png => /home/daniel/wmelite/android/bin/res/drawable-hdpi/ic_launcher.png
   [crunch]   (processed image to cache entry /home/daniel/wmelite/android/bin/res/drawable-hdpi/ic_launcher.png: 0% size of source)
   [crunch] Processing image to cache: /home/daniel/wmelite/android/res/drawable-mdpi/ic_launcher.png => /home/daniel/wmelite/android/bin/res/drawable-mdpi/ic_launcher.png
   [crunch]   (processed image to cache entry /home/daniel/wmelite/android/bin/res/drawable-mdpi/ic_launcher.png: 0% size of source)
   [crunch] Processing image to cache: /home/daniel/wmelite/android/res/drawable-xhdpi/ic_launcher.png => /home/daniel/wmelite/android/bin/res/drawable-xhdpi/ic_launcher.png
   [crunch]   (processed image to cache entry /home/daniel/wmelite/android/bin/res/drawable-xhdpi/ic_launcher.png: 105% size of source)
   [crunch] Processing image to cache: /home/daniel/wmelite/android/res/drawable-xxhdpi/ic_launcher.png => /home/daniel/wmelite/android/bin/res/drawable-xxhdpi/ic_launcher.png
   [crunch]   (processed image to cache entry /home/daniel/wmelite/android/bin/res/drawable-xxhdpi/ic_launcher.png: 59% size of source)
   [crunch] Crunched 4 PNG files to update cache

-package-resources:
     [aapt] Creating full resource package...

-package:
[apkbuilder] Current build type is different than previous build: forced apkbuilder run.
[apkbuilder] Creating SDLActivity-debug-unaligned.apk and signing it with a debug key...

-post-package:

-do-debug:
 [zipalign] Running zip align on final apk...
     [echo] Debug Package: /home/daniel/wmelite/android/bin/SDLActivity-debug.apk
[propertyfile] Creating new property file: /home/daniel/wmelite/android/bin/build.prop
[propertyfile] Updating property file: /home/daniel/wmelite/android/bin/build.prop
[propertyfile] Updating property file: /home/daniel/wmelite/android/bin/build.prop
[propertyfile] Updating property file: /home/daniel/wmelite/android/bin/build.prop

-post-build:

debug:

BUILD SUCCESSFUL
Total time: 21 seconds

I added the complete console output, for you to check at which point it differs at your side. I have not added any game data, so my app would finally not do anything when started. For small game packages, just add game data as assets (renamed to .png, like described in the wiki).

Now you should be able to install the debug build with

Code: [Select]
daniel@androiduser-Aspire-V3-772:~/wmelite/android$ ant installd
Buildfile: /home/daniel/wmelite/android/build.xml

-set-mode-check:

-set-debug-files:

install:
     [echo] Installing /home/daniel/wmelite/android/bin/SDLActivity-debug.apk onto default emulator or device...
     [exec] error: device '(null)' not found
     [exec] - waiting for device -

I do not have a device connected right now, otherwise the app would install (you need to enable developer settings and USB debugging).

Hope it helps.
Logged

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: Android, how to set up project?
« Reply #6 on: October 25, 2015, 11:28:28 AM »

Thanks for the reply, but None of that makes any sense to me. I have never used Android, or command line in my life so I am really confused. Do I move the Ant files into my directory for the WME Android project or do I run it in the Ant directory? Where does the Java directory come into play? So I open the command prompt, then what? Sorry for all the questions and thanks.
Logged

HCDaniel

  • Regular poster
  • ***
  • Karma: 8
  • Offline Offline
  • Posts: 168
    • View Profile
Re: Android, how to set up project?
« Reply #7 on: October 25, 2015, 12:58:01 PM »

I can't give you a complete guide on how to setup your system. But basically, you need to install Java and then ant. For Linux, you simply use the package manager of the distribution. For Windows, you can download an .exe file for installing Java. Then you can download and install ant as per the instructions on the ant website (here http://ant.apache.org/manual/install.html#installing are generic install instructions).

Your install was successful, if you open a command prompt, and type "java" without an error message (like "command not found"), and then repeat the same for "ant".

Finally, the Android SDK (whether installed standalone or in combination with Android Studio) should be in your path as well, so that when you type "android", something else than an error message appears (typically the "Android SDK Manager" GUI should appear). If it doesn't, you should add the "tools" subdirectory from the base directory of the Android SDK to your path, then it should work. (I have set my path as follows:
Code: [Select]
export PATH=$PATH:/opt/android/android-sdk-linux/platform-tools/:/opt/android/android-sdk-linux/tools/ to have both "android" and "adb" (you might need that one later) available in Linux.)

If these commands are available in your command prompt, the build instructions should work. Just go to the "wmelite/android" directory and type the commands.


Logged

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: Android, how to set up project?
« Reply #8 on: October 25, 2015, 01:05:10 PM »

Ok I typed "java" into the command prompt and it comes up, but "android" and "ant" do not. Do I need to put those directories somewhere specifically? When you mentioned to "add the "tools" subdirectory from the base directory of the Android SDK to your path", I am unsure what you meant by that. Do I enter that code you wrote into command prompt? What does that code do? Sorry I am very confused at that point. I am using Windows by the way if that makes a difference. Thanks.
Logged

HCDaniel

  • Regular poster
  • ***
  • Karma: 8
  • Offline Offline
  • Posts: 168
    • View Profile
Re: Android, how to set up project?
« Reply #9 on: October 25, 2015, 01:34:34 PM »

Let me dig out my old windows vista pc, then I'll see how to do this on windows.
Logged

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: Android, how to set up project?
« Reply #10 on: October 25, 2015, 10:54:18 PM »

Thanks you rock  ::rock
Logged

HCDaniel

  • Regular poster
  • ***
  • Karma: 8
  • Offline Offline
  • Posts: 168
    • View Profile
Re: Android, how to set up project?
« Reply #11 on: October 26, 2015, 07:01:41 AM »

Ant installation on Windows (Vista):

  • A "Java Development Kit" (JDK) is required, a "Java Runtime Environment" alone is not sufficient. If there is nothing, or only a JRE installed, please download & install a JDK. In my case, I have a JDK installed here: C:\Program Files\Java\jdk1.7.0_25
  • Download the "binary distribution" of Ant as .zip file. Extract it to your "program files" folder. On my PC it was much faster to extract to the Desktop first, and then move the generated folder to "Program files". I now have a folder "C:\Program Files\apache-ant-1.9.6" with ant, but it is not yet recognized by the system.
  • According to the instructions (http://ant.apache.org/manual/install.html#installing) I need to set 3 environment variables. I go to "System" -> "Advanced System Settings" -> "Environment Variables" (loosely translated to English).
  • I need to add ant's "bin" path to the path variable. "Path" already exists as a system variable, so I add "C:\Program Files\apache-ant-1.9.6\bin" at the end, separated by ";".
  • ANT_HOME and JAVA_HOME do not exist, so I add them as user variables. I set ANT_HOME to "C:\Program Files\apache-ant-1.9.6" and JAVA_HOME to my JDK root "C:\Program Files\Java\jdk1.7.0_25" (I have a rather old JDK).
  • After saving all my changes, I open a new command prompt. Now "ant" is recognized as a command, and (correctly) says sth. like "build.xml not found".
Logged

HCDaniel

  • Regular poster
  • ***
  • Karma: 8
  • Offline Offline
  • Posts: 168
    • View Profile
Re: Android, how to set up project?
« Reply #12 on: October 26, 2015, 07:15:33 AM »

Android SDK standalone install on Windows (Vista):

  • Download and install the "standalone SDK" executable for Windows. I chose "install for all users when prompted". The installer puts all files into this folder "C:\Program Files\Android\android-sdk" and creates some shortcuts in the start menu.
  • Start the "SDK manager" from the start menu as administrator (was required on my PC at least). If unsure, do not deselect anything. If you are sure, deselect the installation of the most recent SDK (currently 6.0) if you want to avoid a big download. Do not deselect anything else.
  • Select "SDK Platform" only for the 2 entries "Android 2.3.3 (API 10)" and "Android 3.1 (API 12)". To see API 12, you need to check "Obsolete" in the bottom of the window. Then, select the most recent "Android SDK build-tools" (currently 23.0.1). Install and then close the SDK manager.
  • For a working command line, the 2 paths "C:\Program Files\Android\android-sdk\tools" (for "android") and "C:\Program Files\Android\android-sdk\platform-tools" (for "adb") need to be in your path. Add them to the "path" environment variable separated by ";". My path variable now has 3 paths added, so it looks like this: "<a looong list of folders...>;C:\Program Files\apache-ant-1.9.6\bin;C:\Program Files\Android\android-sdk\tools;C:\Program Files\Android\android-sdk\platform-tools;"
  • Check that typing "android" in a new command line window will show the SDK manager again (just close it when it appears), and that the "adb" command is recognized.
Logged

piere

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Posts: 301
  • Sorry for any bad english in my posts. Game on !
    • View Profile
Re: Android, how to set up project?
« Reply #13 on: October 26, 2015, 10:03:42 AM »

Ok thanks, I got all that working now. Everytime I try to build the project though, it keeps saying that there is no Build.xml file. But the xml file is there, so I am thinking it keeps looking in the wrong place for it ??
Logged

HCDaniel

  • Regular poster
  • ***
  • Karma: 8
  • Offline Offline
  • Posts: 168
    • View Profile
Re: Android, how to set up project?
« Reply #14 on: October 26, 2015, 10:24:07 AM »

You have a typo. The class is called "FartBlackJack" but the file has the name "FartBlackack.java". Class name and file name must match.
Logged
Pages: [1] 2 3  All
 

Page created in 0.156 seconds with 23 queries.