Android Environment Build Ndk+adt (free Cywgin)

Source: Internet
Author: User


JDK Download:

1http://www.oracle.com/technetwork/java/javase/downloads/index.html2 Configuring environment variables

java_home: create.

The value is: The JDK's installation path on your computer.

PATH: edit.

The value is:%java_home%\bin.

CLASSPATH: Edit.

Configure two values with a value of:.; %java_home%\lib\tools.jar(in which the first value indicates that the JVM First searches the current folder).

3 Test Variables

Open cmd, enter command Java–version and Javac, and if return information is present, the setting is successful.

ADT Download:

Http://dl.google.com/android/adt/adt-bundle-windows-x86_64-20140702.zip

Eclipse + SDK +adt's integration Toolkit can also be built with Eclipse's own first

Extract:

NDK Download

Http://dl.google.com/android/ndk/android-ndk-r10e-windows-x86_64.exe

Extract:

Configuring the SDK and NDK

sdk configuration: adt integrated eclipse The tool is configured by default with sdk

NDK Configuration : Open Eclipse , point WINDOW->PREFERENCES->ANDROID->NDK , set NDK Path


possible issues: The ndk option is not found

Workaround: download NDK component Com.android.ide.eclipse.ndk_23.0.2.1259578.jar. Copy the file "Com.android.ide.eclipse.ndk_23.0.2.1259578.jar" to the Eclipse/plugins folder that comes with the SDK.

: software Baidu Cloud Link: http://pan.baidu.com/s/1qWz5rNApassword:0qhk

Build your first Android project:

1. Create a new Android application project with all the parameters without changing the default values


2. on Project, right-click androidtools->add Nativesupport, named Default. No changes are required.

After confirmation, project builds itself proactivelyJNIthe directory. JNIunder aandroid.mkand theMy-ndk.cppfile. android.mkis aNDKProject'sMakefile,NDKTest.cpp. To beNDKthe source file.

3. encoding NDKTest.cpp

Code:

#include <string.h> #include <jni.h>extern "C" {jstring java_com_example_ndktest_mainactivity_stringjni ( jnienv* env,        jobject thiz) {                   return Env->newstringutf ("hellojni!!");}}


4. Encoding Mainactivity.java

Src->com.example.ndktest->mainactivity.java

Code:

Packagecom.example.ndktest;importandroid.support.v7.app.actionbaractivity;importandroid.os.bundle; Importandroid.view.menu;importandroid.view.menuitem;importandroid.widget.textview; Public Classmainactivity extends Actionbaractivity {static {system.loadlibrary ("Ndktest"                );                       } public native Stringstringjni (); @Override protected voidoncreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate)                    ;                    Textviewtvtext = new TextView (this);                    Tvtext.settext (Stringjni ());                 Setcontentview (Tvtext); @Override Public Booleanoncreateoptionsmenu (Menu menu) {Getmenuinflater ().                    Inflate (R.menu.main, menu);                return true; } @Override Public booleanonoptionsitemselected (MenuItem item) {int id =Item.getitemid ();                    if (id ==r.id.action_settings) {return true;               } return super.onoptionsitemselected (item); }    }


5. Compile the execution. We can.

failure may occur: unable to launch Cygpath. is Cygwin onthe path? Error

How to resolve:

Project Right-click properties->c/c++ build Building settings to remove the Use default Build command and enter ${ndkroot}/ndk-build.cmd


Click on environment in the C + + build, click Add ... Add the environment variable ndkroot, and the value is the root folder of the NDK.

6. Mobile Phone Execution Program

Ability to select the virtual machine AVD or connect directly to the phone. The AVD performs a cumbersome configuration and is recommended to connect directly to the phone. (reference URL http://jingyan.baidu.com/album/6181c3e0618b18152ff15375.html?picindex=4)

Open the Eclipse project and select the Runconfigurations option in run as in target. Remove the third option and select the first option. Then apply, then OK.




Run the project and be able to see the phones that are already connected. Select your phone. For debugging.



--@zl

June 2015 on 30


Android Environment Build Ndk+adt (free Cywgin)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.