1依赖:
compile 'org.greenrobot:greendao:3.2.2' compile 'com.jakewharton:butterknife:8.5.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1' compile 'com.squareup.okhttp3:okhttp:3.10.0' compile 'com.google.code.gson:gson:2.2.4'2权限:
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
3.主布局文件
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.example.retrofitdemo0413.MainActivity"> <TextView android:id="@+id/text_show" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Hello World!"/> <Button android:id="@+id/btn_dianji" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Retrofit?路径请求数据"/> <Button android:id="@+id/btn_dianji2" android:layout_width="match_parent" android:layout_height="wrap_content"