java.lang.NoSuchMethodError:android.support.v4.content.ContextCompat.checkSelfPermission

时间:2016-01-11 11:39:08

标签: java android zxing

尝试在我的应用中集成zxing。

这是gradle文件:

public class Shop
{
    public int Id { get; set; }
    public virtual ICollection<ShopLocation> ShopLocations { get; set; }
}

public class Location
{
    public int Id { get; set; }
    public virtual ICollection<ShopLocation> ShopLocations { get; set; }
}

public class ShopLocation
{
    public int Id { get; set; }
    public virtual Shop Shop { get; set; }
    public virtual Location Location { get; set; }
}

这是ScanActivity.class

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])

    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.android.support:design:22.2.0'
    compile 'net.danlew:android.joda:2.8.1'
    compile 'com.android.support:support-v4:22.2.0'
    compile 'com.github.machinarius:preferencefragment:0.1.1'
    compile 'com.mcxiaoke.volley:library:1.0.16'
    compile 'com.jakewharton:butterknife:6.1.0'
    compile 'com.journeyapps:zxing-android-embedded:3.1.0@aar'
    compile 'com.google.zxing:core:3.2.0'

}

但是我得到了APP崩溃和日志:

package it.xxx.views;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v4.content.ContextCompat;

import com.google.zxing.integration.android.IntentIntegrator;

/**
 * Created by Alessandro on 11/01/2016.
 */
public class ScanActivity extends AppCompatActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        new IntentIntegrator(this).initiateScan(); // `this` is the current Activity

    }
}

感谢您的支持!

0 个答案:

没有答案