網頁

2020年11月19日 星期四

解決Gradle DSL method not found: 'implementation()' 及 更換Android Studio Project的Android Gradle plugin version及Gradle Version

在想要加入新版billing library到舊專案時,一直遇到"Gradle DSL method not found: 'implementation()'"的問題,查了下看起來是Project中Gradle的版本問題, 更換方式如下:

對著app按右鍵選Open Module Settings


再點Project就可以選Android Gradle plugin version及Gradle Version


參考網址:

Gradle DSL method not found: 'implementation()'


2020年11月13日 星期五

解決Service Intent must be explicit

更改舊android專案升到api 28時,一直跳出Service Intent must be explicit,找半天解答,如:Service Intent must be explicit的解决方案【完美解决系列】Service Intent must be explicit,都太複雜,後來看到Google In-App billing, IllegalArgumentException: Service Intent must be explicit, after upgrading to Android L Dev Preview,才了解重點在Intent要設定Package字串,如,我在用的是"com.android.vending.billing.MarketBillingService.BIND",就設定intent.setPackage("com.android.vending"),這樣就OK了


參考網址:

Google In-App billing, IllegalArgumentException: Service Intent must be explicit, after upgrading to Android L Dev Preview

2020年11月6日 星期五

HttpClient won't import in Android Studio

在舊專案中在build.gradle中將compileSdkVersion及targetSdkVersion改成28後,突然出現import org.apache.http.HttpResponse有error,整個都沒了,google了下發現是因為sdk 23就不再包進去了,要另外加入底下的設定

android {
    useLibrary 'org.apache.http.legacy'
}

這樣就OK囉~

參考網址:

HttpClient won't import in Android Studio

2020年10月27日 星期二

解決CI框加的Disallowed Key Characters Error

客戶發生"Disallowed Key Characters"的錯誤回覆,找了朋友及自己的,都看起來正常,本以為請客戶清cache就好,但查了下google才發現是CI本身可能有的狀況,跟cookie有關,但看起來原因實在不是太明白。

一開始找到如何解決CI框架的Disallowed Key Characters錯誤提示的寫法,但發現沒用後來找到如何解決CI框架的Disallowed Key Characters錯誤提示_PHP教程才解決,看起來差在+,有點版本上的問題,總之將

if ( ! preg_match("/^[a-z0-9:_/-]+$/i", $str))

換成

$config = &get_config('config');
if ( ! preg_match("/^[".$config['permitted_uri_chars']."]+$/i", rawurlencode($str))) 

這樣就OK了

參考網址:

如何解決CI框架的Disallowed Key Characters錯誤提示_PHP教程

2020年9月15日 星期二

解決〞Design editor is unavailable until after a successful project sync〞

將舊案從Eclipse匯入到Android studio,點選MainActivity.xml想改畫面卻一直出現底下的訊息
查了下資料,看到這篇android studio 新建一個專案,卻出現Design editor is unavailable until after a successful project sync,看起來點選File -> sync project with Gradle Files,出現Erorr:“The minSdk version should not be declared in the android manifest file. You can move the version from the manifest to the defaultConfig in the build.gradle file.〞

找半天找到AndroidManifes.xml,查看發現有底下這句
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="17"/>

將它mark掉後,再點選File -> sync project with Gradle Files,就build成功可以使用了

參考網址: