ibeacon example of Android development based on Android Studio compilation tool

Source: Internet
Author: User

to see the main content directly under the red letter.

The reason I have access to Android under the ibeacon is because of my own mentor to the task. A URL http://estimote.com/and a sentence: Look at this site, and then try to achieve a docking with ibeacon on the Android phone.

Before this, I have never heard of ibeacon and ble technology, DOT Open the site, found all in English, a closer look to know is about the ibeacon products of the official website. Looked at their demonstration flash, feel quite hanging.

Focus:

Then began to find information. First find is estimote android-sdk, URL Https://github.com/Estimote/Android-SDK Click on the right of the download zip can download its SDK and demos. The SDK has a total of 2 jar packages, one is Estimote-sdk-preview-javadoc.jar and the other is Estimote-sdk-preview.jar.

Download OK, I will first say the above two jar package import it. It was a lot easier to import in eclipse before, and in Android studio it was a bit of a hassle, and I figured it out for a long time.

The following method is excerpted from netizens:

1, the jar package into the project in the Libs folder;2. Select the jar package in project and right-click to select: "Add as library";You can import the project by completing the 2nd step.

Import Com.estimote.sdk.Beacon;

Import com.estimote.sdk.connection.BeaconConnection;

However, the project will appear at compile time, and a 3rd step is required:3, in the Project Build.gradle file Dependencies section to joinDependencies {Compile files (' Libs/android-support-v4.jar ')//This line originally exists, need to add is the following lineCompile files (' Libs/estimote-sdk-preview-javadoc.jar ')//Join this lineCompile files (' Libs/estimote-sdk-preview.jar ')//Join this line}compile the project again, it compiles and runs normally, but when you create a class instance referencing the jar, the system throws an exception noclassdeffounderror, which requires a 4th step;4. Start-run Input cmd for command window;CD-specific project storage locationRun Gradlew.bat cleanThe command execution results are as follows: C:\USERS\WD>CD C:\Users\WD\AndroidStudioProjects\wdLogin C:\users\wd\androidstudioprojects\wdlogin>gradlew.bat CleanThe Taskcontainer.add () method has been deprecated and was scheduled to be removed in Gradle 2.0. Please use the Create () method instead.: Wdlogin:clean BUILD Successful Total time:10.552 secsC:\users\wd\androidstudioprojects\wdlogin>exit  Recompile , it is now working. Ok,jar Package Import, at this time you may be very happy to import the newly downloaded Demos project. After the import, you will likely find that I 艹, how the inside of the Java file of the J icon is all red. The green triangle icon, which is also debugged, turns gray. If you have encountered this problem, I am sorry, the reason I do not know now, if you know, trouble also tell the next brother, the bottom of the message, thank you! Here I offer a workaround. Create a new project and copy and paste the Java files from the Demos project into the new project's Java package. At the same time, the layout of the XML file will be migrated, remember that the jar package you will also be re-imported into the new project.       finally mention the Androidmainfest.xml file modification, first to assign the Bluetooth permission, above the <application to add
 <uses-permission android: Name= "Android.permission.bluetooth"/><< Span class= "pl-ent" >uses-permission android:name="/> 
<Android:name="Com.estimote.sdk.service.BeaconServiceandroid:  Exported="false"/>

At the same time, remember to keep the first line of each Java file the name of the package name to be the same as the package name under the Java file. A... M.. F.xml inside the package= "" also to write the correct package name.
Here, the basic OK.       Let's start debugging. Get here

ibeacon example of Android development based on Android Studio compilation tool

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.