官术网_书友最值得收藏!

Create the project manually

This step is longer in respect to the previous option, but it is useful to know the main differences between these two worlds:

  1. Create a new Android project. Do not forget to set the Minimum SDK to level API 24:
  1. By now, you should create a project with empty activity. Confirm and create the new project.

There are some steps you have to follow before your Android app project turns into an Android Things app project:

  1. Open the Gradle scripts folder and modify build.gradle (app-level) and replace the dependency directive with the following lines:
dependencies {
provided 'com.google.android.things:androidthings:
0.2-devpreview'
}
  1. Open the res folder and remove all the files under it except strings.xml.
  2. Open Manifest.xml and remove the android:theme attribute in the application tag.
  3. In Manifest.xml add the following line inside the application tag:
<uses-library android:name="com.google.android.things"/>
  1. In the layout folder, open all the layout files created automatically and remove the references to values.
  2. In the activity created by default (MainActivity.java) remove this line:
import android.support.v7.app.AppCompatActivity;
  1. Replace AppCompatActivity with Activity.
  2. Under the folder java remove all the folders except the one with your package name.

That's all. You have now transformed an Android app project into an Android Things app project. Compiling the code you will have no errors. In future, you can simply clone the repository holding the project template and start coding.

主站蜘蛛池模板: 彩票| 即墨市| 玛纳斯县| 博野县| 静宁县| 巴彦淖尔市| 临澧县| 杭州市| 莎车县| 芷江| 视频| 隆昌县| 宁德市| 甘孜| 灌云县| 延边| 怀安县| 广德县| 屏东县| 静宁县| 临沂市| 通道| 荥经县| 鄂托克前旗| 宣武区| 郑州市| 专栏| 沙洋县| 陵川县| 龙川县| 潼关县| 南宁市| 容城县| 中方县| 尉犁县| 牟定县| 汉寿县| 常山县| 海南省| 仙桃市| 临沭县|