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

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.

主站蜘蛛池模板: 正镶白旗| 鹤庆县| 宜州市| 周口市| 景宁| 高淳县| 象山县| 运城市| 莫力| 元阳县| 渝北区| 日照市| 休宁县| 新竹市| 安龙县| 大冶市| 拜泉县| 延川县| 库伦旗| 永清县| 克什克腾旗| 东港市| 高陵县| 安丘市| 清河县| 湖北省| 蓝田县| 扶绥县| 酒泉市| 肥乡县| 周口市| 封开县| 阿克苏市| 商河县| 内江市| 富阳市| 大庆市| 海盐县| 永清县| 霍林郭勒市| 调兵山市|