3

I use Vision API to scan barcode. It's almost done, except auto-focus. I follow the guide in this link: https://developers.google.com/android/reference/com/google/android/gms/vision/CameraSource.Builder, use setAutoFocusEnabled method and get an error: "Cannot resolve method 'setAutoFocusEnabled(boolean)'"

My Android studio version: 2.1.1

JRE: 1.8.0

file build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "***"
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.google.android.gms:play-services:7.8+'
}
suco2007
  • 131
  • 1
  • 7
  • `gms:play-services:7.8+`... You realize the latest version of this library is now `10.0`? https://developers.google.com/android/guides/releases – OneCricketeer Nov 23 '16 at 04:29

1 Answers1

2

You are reading newer documentation than the library you are using.

If you want the newer features, then upgrade.

Replace com.google.android.gms:play-services:7.8+

With com.google.android.gms:play-services-vision:10.0.0, or some other, later version than 7.8.

See about selective compilation. It will make your app smaller, and build faster.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • built ok, thanks. I run my app and it doesnot auto-focus. I'm sure that my phone (HTC M8) support auto focus (when I use Camera app). Did I miss something? – suco2007 Nov 23 '16 at 07:26