Android Studio Tips
正直、このツールから始めるのは本当に嫌ですね、何しろ大陸が壁になっているので、いろいろと使い勝手が悪いですから。
1.インストールするとき(セットアップウィザード - コンポーネントのダウンロード)これはダウンロードに長い時間がかかるか、あるいはダウンロードすることはできません(PS:この選択とダウンロード2.25Gコンポーネントは、スタジオでのバグである、誰かがコメントで思い出した、この学生のおかげです。ネットワーク速度は、このステップをスキップしたいことができない場合は、idea.propertiesのbinディレクトリに行を追加することができます:行にdisable.android.first.run=true、Macプラットフォームを右クリックしインストールパッケージ->は、binディレクトリを見つけてパッケージ内容を表示します)。
<スパン 2. 新しいプロジェクトが無事作成されると、Gradleがダウンロードされますが、この作業は壁を登らずにダウンロードすることも可能なようですが、特にアクセスが遅いので、壁を登ってダウンロードすることをお勧めします。では、ダウンロードされたGradleはどこに行くのでしょうか? Open C:\UsersAdministrator.gradle↵wrapper↵dists↵gradle-1.10-all\d90a2yjknzzhpcfgm937zpcte You will see the required version of gradle For example, mine is gradle-1.10.1. 10 I will go to Baidu to search for this download After downloading it, copy gradle-1.10-all.zip to this directory (C:\UsersAdministrator╱ gradle wrapper╱distsgradle-1.10-all╱d90a2yjknzzhpcfgm937zpcte).をダウンロードし、このディレクトリにコピーする。
Note: もし、ビルド中のプロジェクトをインポートする場合、プロジェクトのGradleディレクトリにあるgradle-wrapper.propertiesファイルの配布URLを変更し、最後にダウンロードしたバージョンのgradleに変更します。例えば私はすでに gradle-2.2.1-all.zip を持っていますが gradle-2.4-all.zip を持っていないので distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip に変更します。
プロジェクトをインポートした後、Android Studioをダウンロードしたら、タスクを終了して、プロジェクトのルートにあるbuild.gradleを修正します。
現在のバージョンに変更する
依存関係
<未定義
クラスパス 'com.android.tools.build:gradle:1.2.2' を指定します。
// 注:アプリケーションの依存関係はここに置かないでください。
// 個々のモジュールの build.gradle ファイルに記述します。
}
3. build.gradleの設定について。
メインプロジェクト アプリ :
適用 プラグイン : com.android.application' は、このプロジェクトがメインプロジェクトとして宣言されていることを意味します。
<スパン
依存関係 { <未定義
fileTreeをコンパイルする( ディレ : 'libs' , インクルード : [ '*.jar' ]) デフォルトでは、あまり説明は必要ありません
コンパイルプロジェクト( ':StudioKlowerBase' )} メインプロジェクトが依存するLibraryを宣言し、Libraryと同じ名前であることを確認します。
buildTypes {
release {
minifyEnabled true (means that when the package is signed, it is a full package and obfuscated code will be executed)
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
Define the code obfuscation file Note: proguard-rules.pro should be placed in the main project's directory
}
}
The full code is as follows.
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
applicationId "com.klowerbase.test"
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':StudioKlowerBase')
}
Configuration of the --Library project
apply plugin: 'android-library' defined as Library
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2' defines the version of gradle to be compiled
}
The full code is as follows.
buildscript {
repositories {
mavenCentral()
mavenCentral() }
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
}
}
apply plugin: 'android-library'
dependencies {
compile fileTree(include: '*.jar', dir: 'libs')
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of their default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
The configuration of the project The code is as follows
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
repositories { jcenter()
dependencies {
classpath 'com.android.tools.build:gradle:1.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Solve Task '' not found in root project '***'.
Method 1: Delete the <component name="FacetManager"> in the .iml ... </component>
Method 2: Delete the .iml and .idea folders and re-import the program
After experiments: the second method works
Since I used gradle-2.2.1, the project structure has changed a bit, as shown in the following screenshot.
<img src="https://img-blog.csdn.net/20150720130051120?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/ 400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
Finally, some common shortcuts are included.
The full code is as follows.
apply plugin: 'com.android.application' android { compileSdkVersion 19 buildToolsVersion "19.1.0" defaultConfig { applicationId "com.klowerbase.test" minSdkVersion 11 targetSdkVersion 19 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile project(':StudioKlowerBase') }
Configuration of the --Library project
apply plugin: 'android-library' defined as Library
dependencies { classpath 'com.android.tools.build:gradle:1.2.2' defines the version of gradle to be compiled
}
The full code is as follows.
buildscript { repositories { mavenCentral() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:1.2.2' } } apply plugin: 'android-library' dependencies { compile fileTree(include: '*.jar', dir: 'libs') } android { compileSdkVersion 19 buildToolsVersion "19.1.0" sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } // Move the tests to tests/java, tests/res, etc... instrumentTest.setRoot('tests') // Move the build types to build-types/<type> // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ... // This moves them out of their default location under src/<type>/... which would // conflict with src/ being used by the main source set. // Adding new build types or product flavors should be accompanied // by a similar customization. debug.setRoot('build-types/debug') release.setRoot('build-types/release') } }
The configuration of the project The code is as follows
// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { jcenter() repositories { jcenter() dependencies { classpath 'com.android.tools.build:gradle:1.2.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() } }
Solve Task '' not found in root project '***'. Method 1: Delete the <component name="FacetManager"> in the .iml ... </component> Method 2: Delete the .iml and .idea folders and re-import the program After experiments: the second method works Since I used gradle-2.2.1, the project structure has changed a bit, as shown in the following screenshot.
<img src="https://img-blog.csdn.net/20150720130051120?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/ 400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
Finally, some common shortcuts are included.
Ctrl+Alt+L フォーマットコード
Ctrl+Alt+space コードヒント
Ctrl+Alt+O インポートされたクラスとパッケージの最適化
Alt+Insert コードを生成する(例:get、setメソッド、コンストラクターなど)
Ctrl+Shift+Space のオートコンプリートコード
Ctrl+Space コードヒント
Ctrl+R 置換
Ctrl+Y 行の削除(Ctrl+Xは行の削除ではなく、切り取りです。チェックをはずすと、その行が落ちそうなときにカットされます) Ctrl+D 行をコピーする Ctrl+/ または Ctrl+Shift+/ 注釈 (// または /*... */)
関連
-
よくあるJavaのエラー50選(その1)
-
Androidアップグレード/ブラシ戦略(GoogleネイティブシステムPixel)
-
エラー:SSLピアが正しくシャットダウンされない
-
AndroidにおけるActivity/ActionBarActivity/AppCompatActivityの区別と理解について
-
Android.view.InflateException: バイナリ XML ファイルの行番号 0: クラス <unknown> を展開する際のエラー 解決方法
-
Error:Execution failed for task ':app:processDebugResources'. に対する解決策は
-
アンドロイドスタジオに角丸ボタンが実装される
-
コンパレータの例外です。比較メソッドは一般契約に違反する!
-
Androidネットワークフレームワーク Volley
-
progressBarを使ってロードアニメーションとロードプログレスバーを実装する - 白人の必須アイテム (V)
最新
-
nginxです。[emerg] 0.0.0.0:80 への bind() に失敗しました (98: アドレスは既に使用中です)
-
htmlページでギリシャ文字を使うには
-
ピュアhtml+cssでの要素読み込み効果
-
純粋なhtml + cssで五輪を実現するサンプルコード
-
ナビゲーションバー・ドロップダウンメニューのHTML+CSSサンプルコード
-
タイピング効果を実現するピュアhtml+css
-
htmlの選択ボックスのプレースホルダー作成に関する質問
-
html css3 伸縮しない 画像表示効果
-
トップナビゲーションバーメニュー作成用HTML+CSS
-
html+css 実装 サイバーパンク風ボタン
おすすめ
-
AndroidStdioのインストール時に「メインクラスが見つからない com/intelligi/idea/Main」というエラーが発生する。
-
Android Studioプロジェクトをインポートすると、無効なgradle jdkコンフィギュレーションが見つかったと報告される
-
エラーの解決方法 URIがandroid studioのxmlファイルに登録されていない。
-
テスト、Eclipseは "エラーが発生しました、詳細はエラーログを参照してください。 java.lang.NullPointerException" を報告します。
-
Android 開発 キーボード イベント モバイル ミッキーマウス ケース
-
Android studioでTextViewのフォントを変更する2つの方法(例:模造歌、公式スクリプト)。
-
AndroidManifest.xml ファイルが見つからない 解決策
-
APKのインストール: 失敗 [INSTALL_PARSE_FAILED_NO_CERTIFICATES]
-
再試行したい場合は、手動で adb.exe を kill し、'restart' をクリックしてください。
-
二次元コード読み取り機能のAndroid実装(a) - ZXingプラグインアクセス