Translate

BTemplates.com

Powered by Blogger.

2017年11月3日金曜日

2017-11-02 到達点メモ


昨日の続き
よく見たら、昨日の記事にVoiceTimerをKotlin化するとか書いていないが
昨日からそれの作業をしている。

おそらくkotlinに変換した場合が原因だと思われるのだが
どうもcontextとは予約語の一部として採用されている節がある。
kotlinは、get/setを使わないで全部変数で採用する部分があったので
その影響を受けている節がある
単に、変数として使っているだけなら、名前は変えたほうが良い

具体的には、以下のような注釈が付く
Call requires API level 23 (current min is 21): android.app.Fragment#getContext less... (Ctrl+F1)
This check scans through all the Android API calls in the application and warns about any calls that are not available on all versions targeted by this application (according to its minimum SDK attribute in the manifest).  If you really want to use this API and don't need to support older devices just set the minSdkVersion in your build.gradle or AndroidManifest.xml files.  If your code is deliberately accessing newer APIs, and you have ensured (e.g. with conditional execution) that this code will only ever be called on a supported platform, then you can annotate your class or method with the @TargetApi annotation specifying the local minimum SDK to apply, such as @TargetApi(11), such that this check considers 11 rather than your manifest file's minimum SDK as the required API level.  If you are deliberately setting android: attributes in style definitions, make sure you place this in a values-vNN folder in order to avoid running into runtime conflicts on certain devices where manufacturers have added custom attributes whose ids conflict with the new ones on later platforms.  Similarly, you can use tools:targetApi="11" in an XML file to indicate that the element will only be inflated in an adequate context.

あと、注意事項として、Record Espresso Testを行う場合、
自動生成されるのがjavaファイルなので気を付ける事

ただし、単純にktファイルに変換しても動かないようである
ちょっと調べてみたが、いまいち原因が掴めないため
テストコードだけはjavaで書いた方が楽かも

あと、kotlinでは、イテレーターが使えるため
for(i in 1..9)のような書き方ができる。
これが使えると本当に便利。

あと、下記のようなエラーが出た場合、Rebulidして再度Runをすれば動く

java.lang.RuntimeException: Unable to instantiate application com.aaa.nononaga.voicetimerr.ClassNoticeManager: java.lang.ClassNotFoundException: Didn't find class "com.aaa.nononaga.voicetimerr.ClassNoticeManager" on path: DexPathList[[zip file "/data/app/com.aaa.nononaga.voicetimerr-2/base.apk", zip file "/data/app/com.aaa.nononaga.voicetimerr-2/split_lib_dependencies_apk.apk", zip file "/data/app/com.aaa.nononaga.voicetimerr-2/split_lib_slice_0_apk.apk", zip file "/data/app/com.aaa.nononaga.voicetimerr-2/split_lib_slice_1_apk.apk", zip file "/data/app/com.aaa.nononaga.voicetimerr-2/split_lib_slice_2_apk.apk", zip file "/data/app/com.aaa.nononaga.voicetimerr-2/split_lib_slice_3_apk.apk", zip file "/data/app/com.aaa.nononaga.voicetimerr-2/split_lib_slice_4_apk.apk", zip file "/data/app/com.aaa.nononaga.voicetimerr-2/split_lib_slice_5_apk.apk", zip file "/data/app/com.aaa.nononaga.voicetimerr-2/split_lib_slice_6_apk.apk", zip file "/data/app/com.aaa.nononaga.voicetimerr-2/split_lib_slice_7_apk.apk", zip file "/data/app/com.aaa.nononaga.voicetimerr-2/split_lib_slice_8_apk.apk", zip file "/data/app/com.aaa.nononaga.voicetimerr-2/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.aaa.nononaga.voicetimerr-2/lib/arm, /system/lib, /vendor/lib]]

ひとまず、VoiceTimerが一通り動くことは確認できたので今日はここまで

0 コメント:

コメントを投稿