I created a chat project using android studio 1.0.1
this is the gradle build properties
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "chat.mchattrav.chattrav"
minSdkVersion 5
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
when I run the application I get this error message Immediately
unfortunately app has stopped
when I debug the application I get this exception information
java.lang.NoSuchMethodError: android.os.StatFs.getBlockSizeLong
It seems like I used lower api level than "18" which required by this method
can I solve this problem without the need to increase the api level "minSdkVersion"?
can I use the support library instead ?
If you need to support SDK lower then 18, then you need to handle that.
Exists 2 methods:
public int getBlockSize () Added in API1, was deprecated at API18
and
public long getBlockSizeLong () Added in API18
Your project use 2nd one, you need to find all usages and care about running android version, for example
StatFs staFs = new StatFs("path");
long size = 0;
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2){
size = staFs.getBlockSizeLong();
}else {
size = staFs.getBlockSize();
}
// use size ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With