Apk的构建不正确

时间:2018-10-16 16:48:56

标签: java android firebase gradle

我创建了一个Android应用。在我的应用中,它与Firebase连接。因此,当有人输入姓名,手机号码,血型,FB ID等任何数据时,他们都会存储在实时数据库中。当人们使用血型进行搜索时,它会显示姓名,手机号码和FB ID。此外,我还添加了地图,当人们单击以显示地图时,它会显示地图上的位置。但是,当我通过android studio将项目部署到设备上时,它可以正常工作。没有问题显示。但是,当我对其进行签名并生成具有签名的发行版apk时,我将其手动安装到设备中,然后两个功能消失了。

第一个:它不显示Facebook ID。它显示为空,如果有人输入facebook id,那么它在数据库中什么也不存储。即使我在数据库中手动输入了fb child,它也会显示一条空消息。

第二个问题:地图无法正确存储位置,也不会显示任何地图。

可能是什么问题?

这是我的数据提交活动:

    public class DonorForm extends AppCompatActivity {
    Spinner batchChoice;
    Spinner groupChoice;

    EditText Name;
    EditText Mobile;
    EditText Fb;

    Button Save;

    ProgressBar progressBar;



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

        batchChoice = (Spinner) findViewById(R.id.dropdownBatch);

        String[] batchs = new String[]{"N-15","N-16", "N-17", "N-18","N-19", "N-20", "N-21", "N-22","N-23","N-24","N-25", "N-26","N-27", "N-28", "N-29", "N-30","N-31","N-32", "N-33", "N-34","N-35", "N-36", "N-37", "N-38","N-39", "N-40","N-41","N-42","N-43", "N-44","N-45", "N-46", "N-47", "N-48","N-49","N-50", "N-51", "N-52","N-53", "N-54", "N-55", "N-56","N-57", "N-58", "N-59", "N-60","BDS-1", "BDS-2","BDS-3", "BDS-4", "BDS-5", "BDS-6","BDS-7", "BDS-8", "BDS-9", "BDS-10","BDS-11", "BDS-12","BDS-13", "BDS-14", "BDS-15", "BDS-16","BDS-17", "BDS-18", "BDS-19", "BDS-20"};
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, batchs);
        batchChoice.setAdapter(adapter);


        groupChoice = (Spinner) findViewById(R.id.dropdownGroup);
        String[] group = new String[]{"O+","O-", "A+", "B+","A-", "B-", "AB+", "AB-"};
        ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, group);
        groupChoice.setAdapter(adapter1);

        Name = (EditText) findViewById(R.id.edt_name);
        Mobile = (EditText) findViewById(R.id.edt_mobileNumber);
        Fb = (EditText) findViewById(R.id.edt_fb);

        Save = (Button) findViewById(R.id.btn_saveDonor);

        Save.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String name = Name.getText().toString();
                String batch = batchChoice.getSelectedItem().toString();
                String group = groupChoice.getSelectedItem().toString();
                String mobile = Mobile.getText().toString();
                String lat = MainActivity.lat.toString();
                String lng = MainActivity.lng.toString();
                String fb = Fb.getText().toString();


                if(fb.length()>20 )
                {
                    Toast.makeText(DonorForm.this, "Please Enter valid facebook username", Toast.LENGTH_SHORT).show();
                }
                else{ if(name.length()>25 )
                {
                    Toast.makeText(DonorForm.this, "Please Enter less than 25 character", Toast.LENGTH_SHORT).show();
                }
                else {if(mobile.length()<11 ||mobile.length()>11 )
                {
                    Toast.makeText(DonorForm.this, "Please Enter 11 Digit Mobile Number", Toast.LENGTH_SHORT).show();
                }
                else
                {
                    Donor donor = new Donor(name,mobile,group,batch,lat, lng,fb);
                    DatabaseReference myRef = database.getReference("donors");
                    myRef.child(batch).child(group).push().setValue(donor);

                    finish();
                }}


                }

            }
        });

    }
}

这是我从Firebase进行数据查看的活动:  按钮buttonMap;

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

    Bundle extras = getIntent().getExtras();
    city = extras.getString("city");
    group = extras.getString("group");
    Log.i("NAME",city);
    Log.i("NAME",group);

    donorList = new ArrayList<>();
    donorInfo = new ArrayList<>();
    listView = (ListView) findViewById(R.id.list_donor);
    arrayAdapter = new ArrayAdapter<String>(this, R.layout.list_item, R.id.list, donorList);
    listView.setAdapter(arrayAdapter);

    buttonMap = (Button) findViewById(R.id.Button_mapShow);
    buttonMap.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startActivity(new Intent(DonorList.this, MapsActivity.class));
        }
    });



    DatabaseReference myRef = database.getReference("donors");

    myRef.child(city).child(group).addChildEventListener(new ChildEventListener() {

        @Override
        public void onChildAdded(DataSnapshot dataSnapshot, String s) {
            Donor donor = dataSnapshot.getValue(Donor.class);
            donorInfo.add(donor);
            String donorInfo = "Name : "+ donor.name + "   \nNumber : " + donor.contuctNumber + "   \nFb Username: " + donor.fb;
            donorList.add(donorInfo);
            arrayAdapter.notifyDataSetChanged();
        }

        @Override
        public void onChildChanged(DataSnapshot dataSnapshot, String s) {

        }

        @Override
        public void onChildRemoved(DataSnapshot dataSnapshot) {

        }

        @Override
        public void onChildMoved(DataSnapshot dataSnapshot, String s) {

        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });
}

这是地图的可加性

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

    private GoogleMap mMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }

    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;

        // Add a marker in Sydney and move the camera
        LatLng you = new LatLng(MainActivity.lat, MainActivity.lng);
        mMap.addMarker(new MarkerOptions().position(you).title("Your Position").icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)));
        mMap.moveCamera( CameraUpdateFactory.newLatLngZoom(you , 15.0f) );


        for(int i=0; i<DonorList.donorInfo.size(); i++){
            Log.d("Donor", String.valueOf(i));


            Donor donor = DonorList.donorInfo.get(i);
            Double lat = new Double(donor.lat);
            Double lng = new Double(donor.lan);

            Log.d("Donor", donor.lat);
            Log.d("Donor", donor.lan);


            LatLng donar = new LatLng(lat, lng);
            String donorName = donor.name+ " " + donor.contuctNumber;
            mMap.addMarker(new MarkerOptions().position(donar).title(donorName));
        }
    }
}

这是gradle.build模块文件:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "com.nissan.dnmcbloodbank"
        minSdkVersion 15
        targetSdkVersion 26
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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

    implementation 'com.android.support:appcompat-v7:26.0.0'
    implementation 'com.android.support:animated-vector-drawable:26.0.0'
    implementation 'com.android.support:mediarouter-v7:26.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.google.firebase:firebase-core:9.8.0'
    implementation 'com.google.firebase:firebase-core:9.8.0'
    implementation 'com.google.firebase:firebase-config:9.8.0'
    implementation 'com.google.firebase:firebase-crash:9.8.0'
    implementation 'com.firebase:firebase-client-android:2.3.1'
    implementation 'com.google.android.gms:play-services-auth:9.8.0'
    implementation 'com.google.android.gms:play-services-location:9.8.0'
    implementation 'com.google.android.gms:play-services:9.8.0'
    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.4'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

apply plugin: 'com.google.gms.google-services'

0 个答案:

没有答案