简体   繁体   English

Gimbal Github演示不适用于Android,也没有显示为什么不起作用

[英]Gimbal Github demo doesn't work for Android and doesn't show why it's not working

I opened the Github project from Gimbal into android studio and let it update all the gradle properties. 我从Gimbal将Github项目打开到android studio中,并让它更新了所有gradle属性。 But when I try to run the project it doesn't discover any beacons and the worst part is that there is no errors in the logcat that point out what the problem is. 但是,当我尝试运行该项目时,它没有发现任何信标,最糟糕的部分是logcat中没有错误指出问题所在。

Here's the code that I ran: 这是我运行的代码:

public class MainActivity extends Activity {

private PlaceManager placeManager;
private BeaconManager bm;
private PlaceEventListener placeEventListener;
private ArrayAdapter<String> listAdapter;
private ListView listView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    listAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_expandable_list_item_1);
    listView = (ListView) findViewById(R.id.list);
    listView.setAdapter(listAdapter);

    listAdapter.add("Setting Gimbal API Key");
    listAdapter.notifyDataSetChanged();
    Gimbal.setApiKey(this.getApplication(), "my api code ");

    bm = new BeaconManager();
    bm.addListener(new BeaconEventListener() {
        @Override
        public void onBeaconSighting(BeaconSighting beaconSighting) {

            super.onBeaconSighting(beaconSighting);

            Log.d("beacon1", beaconSighting.getBeacon().toString());
            Log.d("beacon2", String.format("", beaconSighting.getRSSI()));
        }
    });
    bm.startListening();


    placeEventListener = new PlaceEventListener() {

        @Override
        public void onVisitStart(Visit visit) {

            super.onVisitStart(visit);

            listAdapter.add(String.format("Start Visit for %s", visit.getPlace().getName()));
            listAdapter.notifyDataSetChanged();

            Log.d("1", String.valueOf(visit.getArrivalTimeInMillis()));
            Log.d("2", String.valueOf(visit.getDepartureTimeInMillis()));
            Log.d("3", String.valueOf(visit.getPlace()));
            Log.d("4", String.valueOf(visit.getDwellTimeInMillis()));
            BeaconSighting demo = new BeaconSighting();
            Beacon beac = demo.getBeacon();
            Log.d("", beac.getUuid());
        }

        @Override
        public void onVisitEnd(Visit visit) {

            super.onVisitEnd(visit);

            listAdapter.add(String.format("End Visit for %s", visit.getPlace().getName()));
            listAdapter.notifyDataSetChanged();

            Log.d("ending", "ending");
        }
    };

    placeManager = PlaceManager.getInstance();
    placeManager.addListener(placeEventListener);
    placeManager.startMonitoring();

    CommunicationManager.getInstance().startReceivingCommunications();
}}

Thanks in advance. 提前致谢。

EDIT 1: 编辑1:

I get a warning when building the apk. 构建APK时收到警告。

Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(com.gimbal.location.established.e) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
Error:(com.gimbal.location.established.f) that doesn't come with an
Error:associated EnclosingMethod attribute. This class was probably produced by a
Error:compiler that did not target the modern .class file format. The recommended
Error:solution is to recompile the class from source, using an up-to-date compiler
Error:and without specifying any "-target" type options. The consequence of ignoring
Error:this warning is that reflective operations on this class will incorrectly
Error:indicate that it is *not* an inner class.

I found my mistake: 我发现了我的错误:

When changing my package I forgot to change the applicationId aswell (build.gradle). 更改程序包时,我也忘记更改applicationId(build.gradle)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM