日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

菜鸟的Android之路-02《eclipse新建android project》

發布時間:2023/12/20 Android 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 菜鸟的Android之路-02《eclipse新建android project》 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

創建項目

選擇android項目

選擇android應用的版本。warning自己看提示。

以下都是默認的,不要問我什么意思,我英語4級還沒過。

還是默認

依然默認

仍舊默認

果然悲劇還是發生了,報錯了

[2015-01-11 12:09:46 - test] D:\JavaProject\test\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
[2015-01-11 12:09:46 - test]
[2015-01-11 12:09:46 - test] D:\JavaProject\test\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
[2015-01-11 12:09:46 - test]
[2015-01-11 12:09:46 - test] D:\JavaProject\test\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
[2015-01-11 12:09:46 - test]
[2015-01-11 12:09:49 - test] D:\JavaProject\test\res\values\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
[2015-01-11 12:09:49 - test]
[2015-01-11 12:09:49 - test] D:\JavaProject\test\res\values-v11\styles.xml:7: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'.
[2015-01-11 12:09:49 - test]
[2015-01-11 12:09:49 - test] D:\JavaProject\test\res\values-v14\styles.xml:8: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
[2015-01-11 12:09:49 - test]

百度紅色字體后,參考貼:http://www.apkbus.com/android-182059-1-1.html

當我看到extras時,好像似曾相識,于是果斷打開SDK Manager.exe

果斷把extras下載了,再去看對應的文件夾發現東西變多了,原來是空的。

后來實踐發現”其實下載android開頭的兩個和GOOGLE USB Driver“即可

沒有按照參考貼的做法,想想東西已經有了,再新建一次就行了,于是又喜聞樂見地悲劇了,錯誤更多了。形式和上圖差不多,也是這個沒有那個沒有。但是之前提示的'Theme.AppCompat.Light'沒有再提示了。這就說明了,這個處理方法是對的。然后再仔細看了參考貼,明白了這些提示都是SDK下載不全的問題:(請看后文這是不對的!

minimum required SDK:? miniSdk, 是你程序最低支持的SDK版本,度娘知道說一般miniSDK設定一般為8或者10

target SDKProject的目標SDK版本

Complie with當前SDK的版本

Theme:主題。應該是一些外觀問題。

參考貼:http://stackoverflow.com/questions/26431676/appcompat-v721-0-0-no-resource-found-that-matches-the-given-name-attr-andro? 全英文的,看不懂的,去廁所自己哭吧。很激動,第一個project就要好了!

英文不好的結果就是依然悲劇。還是報錯,但是報錯信息變化了,大部分報錯是“appcompat_v7\res\values-v21\styles_base.xml”。查詢后發現很多人在更新了ADT和SDK后(15年最新版本)都有這個問題。結論是minimum required SDK選的版本太低了。為了向下兼容多出了一個appcompat_v7項目。appcompat_v7項目的報錯并不影響編碼。

表達不清,參考貼:http://jingyan.baidu.com/article/3ea51489e04eb852e61bbaa4.html

把最低版本的SDK提高,就解決了這個“appcompat_v7”多余項目的問題,個人感覺在后期程序實際運行的時候還是會出現問題的,畢竟有這個“appcompat_v7”project的出現。但是現在先不管,讓它去屎!

項目創建完畢的界面好激動!

?

還是網上找的簡單程序實例,尼瑪還是有錯的,原帖我就不發了。

JAVA文件內容如下。

package?com.daniel.test; import?android.app.Activity; import?android.os.Bundle; import?android.view.Menu; import?android.view.MenuItem; import?android.view.View; import?android.view.View.OnClickListener; import?android.widget.Button; import?android.widget.TextView; import?android.graphics.Color; public?class?MainActivity?extends?Activity?implements?OnClickListener?{TextView?tv_show=null;Button?greenBtn=null;Button?blueBtn=null;Button?yellowBtn=null;@Overrideprotected?void?onCreate(Bundle?savedInstanceState)?{super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);tv_show=(TextView)findViewById(R.id.showWord);greenBtn=(Button)findViewById(R.id.GreenBtn);blueBtn=(Button)findViewById(R.id.BlueBtn);yellowBtn=(Button)findViewById(R.id.YellowBtn);greenBtn.setOnClickListener(this);blueBtn.setOnClickListener(this);yellowBtn.setOnClickListener(this);}@Overridepublic?void?onClick(View?v)?{switch?(v.getId())?{case?R.id.GreenBtn:tv_show.setTextColor(Color.RED);tv_show.setText("Lucky!Good?Man!");break;case?R.id.BlueBtn:tv_show.setTextColor(Color.BLUE);tv_show.setText("Do?you?love?Mary?");break;case?R.id.YellowBtn:tv_show.setTextColor(Color.YELLOW);tv_show.setText("Be?Careful!Poor?Man!");break;default:break;}}@Overridepublic?boolean?onCreateOptionsMenu(Menu?menu)?{//?Inflate?the?menu;?this?adds?items?to?the?action?bar?if?it?is?present.getMenuInflater().inflate(R.menu.main,?menu);return?true;}@Overridepublic?boolean?onOptionsItemSelected(MenuItem?item)?{//?Handle?action?bar?item?clicks?here.?The?action?bar?will//?automatically?handle?clicks?on?the?Home/Up?button,?so?long//?as?you?specify?a?parent?activity?in?AndroidManifest.xml.int?id?=?item.getItemId();if?(id?==?R.id.action_settings)?{return?true;}return?super.onOptionsItemSelected(item);} }

XML文件如下:

?<RelativeLayout?xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingBottom="@dimen/activity_vertical_margin"android:paddingLeft="@dimen/activity_horizontal_margin"android:paddingRight="@dimen/activity_horizontal_margin"android:paddingTop="@dimen/activity_vertical_margin"tools:context=".MainActivity"?><TextViewandroid:id="@+id/showWord"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignLeft="@+id/GreenBtn"android:layout_alignParentTop="true"android:layout_alignRight="@+id/BlueBtn"android:layout_marginTop="17dp"android:text="Do?you?love?Mary?"android:textStyle="bold"?/><Buttonandroid:id="@+id/GreenBtn"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_below="@+id/showWord"android:layout_marginLeft="22dp"android:layout_marginTop="28dp"android:gravity="left|center_vertical|center_horizontal"android:text="Yes!"?/><Buttonandroid:id="@+id/BlueBtn"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignBaseline="@+id/YellowBtn"android:layout_alignBottom="@+id/YellowBtn"android:layout_toRightOf="@+id/YellowBtn"android:gravity="left|center_vertical|center_horizontal"android:text="Again"?/><Buttonandroid:id="@+id/YellowBtn"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignBaseline="@+id/GreenBtn"android:layout_alignBottom="@+id/GreenBtn"android:layout_toRightOf="@+id/GreenBtn"android:gravity="left|center_vertical|center_horizontal"android:text="No~"?/> </RelativeLayout>

直接保存。然后就可以運行了。

A、先說AVD虛擬機運行。

RUN邊上的下三角,點擊配置

?

target前兩個選項都是真機運行的。第三個是AVD虛擬機。如果沒有虛擬機,就新建一個。具體方法看“菜鳥的Android之路-01”。如果你有真機,強烈建議用真機,因為AVD真的是“很慢”!!!

B、再說真機運行。

先上參考貼:http://www.cnblogs.com/lanxuezaipiao/archive/2013/03/11/2953564.html

提示,所有你能搜索到的帖子對于路徑都高度統一,為“X:xxx\android-sdk-windows\tools”,但是我使用的SDK路徑有點差別,為“X:xxx\android-sdk-windows\platform-tools“,該目錄下有ADB.EXE。可能是版本問題,或者其他原因,不高興去查。

簡而言之:

1、先把真機連接到電腦上,把驅動裝好,什么豌豆莢,91,360,各種助手隨便HIGH.

2、配置run configuration

然后就是真機界面,如圖,屌絲極品機,紅米NOTE。

?

轉載于:https://my.oschina.net/u/1458938/blog/368870

總結

以上是生活随笔為你收集整理的菜鸟的Android之路-02《eclipse新建android project》的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。