Android IDE (AIDE) Support Forum

App Stopped Working

I am making an app. But, when it has compiled and i run it, it says “Unfortunately, the package installer has stopped…” I don’t have an idea what is wrong about it.

MainActivity.java:
package jund.fauz.lk;

import android.;
import android.app.
;
import android.content.;
import android.content.pm.
;
import android.os.;
import android.support.v4.app.
;
import android.support.v4.content.;
import android.text.
;
import android.view.;
import android.widget.
;
import jund.fauz.kebutuhan.;
import jund.fauz.libraries.
;
import jund.fauz.lk.*;

public class MainActivity extends Activity
{
Boolean valid = false, izin;
int int_tanggal, int_bulan, int_tahun, int_uangm, int_uangk, int_valid = 0, PERMISSION_CODE = 1;
String str_bulan, str_ket;
String[] arr_bulan = {“Januari”, “Februari”, “Maret”, “April”, “Mei”, “Juni”, “Juli”, “Agustus”, “September”, “Oktober”, “November”, “Desember”};

LinearLayout layout_waktu;
Switch sw_hari_ini;
EditText et_tanggal, et_tahun, et_uangm, et_uangk, et_ket;
AutoCompleteTextView actv_bulan;
Button bt_simpan;

@Override
protected void onCreate(Bundle savedInstanceState)
{
	// TODO: Implement this method
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);
	izin();
	buat_tab();
	deklarasi();
	on_klik();
}

public void buat_tab(){
	// Buat TabHost
	TabHost tab = (TabHost) findViewById(R.id.tab_h);
	tab.setup();
	
	// Tab 1
	TabHost.TabSpec ts = tab.newTabSpec("");
	ts.setContent(R.id.tab1);
	ts.setIndicator("Laporan Baru");
	tab.addTab(ts);

	// Tab 2
	ts = tab.newTabSpec("");
	ts.setContent(R.id.tab2);
	ts.setIndicator("Laporan Lama");
	tab.addTab(ts);

	// Tab 3
	ts = tab.newTabSpec("");
	ts.setContent(R.id.tab3);
	ts.setIndicator("Pengaturan");
	tab.addTab(ts);

}

public void deklarasi(){
	// Deklarasi Layout
	layout_waktu = (LinearLayout) findViewById(R.id.layout_waktu);
	sw_hari_ini = (Switch) findViewById(R.id.switch_hari_ini);
	et_tanggal = (EditText) findViewById(R.id.tanggal);
	actv_bulan = (AutoCompleteTextView) findViewById(R.id.bulan);
	et_tahun = (EditText) findViewById(R.id.tahun);
	et_uangm = (EditText) findViewById(R.id.uang_masuk);
	et_uangk = (EditText) findViewById(R.id.uang_keluar);
	et_ket = (EditText) findViewById(R.id.keterangan);
	bt_simpan = (Button) findViewById(R.id.button_simpan);
	
	// Mengatur adapter
	ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, arr_bulan);
	actv_bulan.setAdapter(adapter);
}

public void on_klik(){
	sw_hari_ini.setOnClickListener(new View.OnClickListener(){
		@Override
		public void onClick(View v){
			if(sw_hari_ini.isChecked()){
				layout_waktu.setVisibility(View.GONE);
			} else {
				layout_waktu.setVisibility(View.VISIBLE);
			}
		}
	});
	bt_simpan.setOnClickListener(new View.OnClickListener(){
		@Override
		public void onClick(View v){
			valid();
			if(valid){
				simpan();
			}
		}
	});
}

public void valid(){
	if(!sw_hari_ini.isChecked()){
		if(TextUtils.isEmpty(et_tanggal.getText().toString().trim())){
			et_tanggal.setError("Tanggal tidak boleh kosong");
			int_valid++;
		}
		if(TextUtils.isEmpty(actv_bulan.getText().toString().trim())){
			actv_bulan.setError("Bulan tidak boleh kosong");
			int_valid++;
		}
		if(TextUtils.isEmpty(et_tahun.getText().toString().trim())){
			et_tahun.setError("Tahun tidak boleh kosong");
			int_valid++;
		}
	}
	if(TextUtils.isEmpty(et_uangm.getText().toString().trim())){
		et_uangm.setError("Uang Masuk tidak boleh kosong");
		int_valid++;
	}
	if(TextUtils.isEmpty(et_uangk.getText().toString().trim())){
		et_uangk.setError("Uang Keluar tidak boleh kosong");
		int_valid++;
	}
	if(TextUtils.isEmpty(et_ket.getText().toString().trim())){
		et_ket.setError("Keterangan tidak boleh kosong");
		int_valid++;
	}
	if(int_valid==0){
		valid = true;
	} else {
		valid = false;
	}
	int_valid = 0;
}

public void simpan(){
	LK lk;
	if(sw_hari_ini.isChecked()){
		lk = new LK(Integer.parseInt(et_uangm.getText().toString()), Integer.parseInt(et_uangk.getText().toString()), et_ket.getText().toString(), true);
	} else {
		lk = new LK(Integer.parseInt(et_tanggal.getText().toString()), actv_bulan.getText().toString(), Integer.parseInt(et_tahun.getText().toString()), Integer.parseInt(et_uangm.getText().toString()), Integer.parseInt(et_uangk.getText().toString()), et_ket.getText().toString(), true);
	}
	if(File.apakahAda(Environment.getExternalStoragePublicDirectory("/LK")+"/"+String.valueOf(lk.id()))){
		Toast.makeText(getApplicationContext(),
			"Laporan berhasil disimpan",
			Toast.LENGTH_SHORT).show();
	} else {
		Toast.makeText(getApplicationContext(),
		 	"Gagal menyimpan laporan!",
			Toast.LENGTH_SHORT).show();
	}
}

public void izin(){
	if(ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE)==PackageManager.PERMISSION_DENIED){
		if(ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)){
			new AlertDialog.Builder(this)
			.setTitle("Izin Dibutuhkan")
			.setMessage("Izin penyimpanan dibutuhkan supaya aplikasi bisa menyimpan laporan. Harap izinkan aplikasi.")
			.setPositiveButton("Oke", new DialogInterface.OnClickListener(){
				@Override
				public void onClick(DialogInterface dialog, int which){
					ActivityCompat.requestPermissions(MainActivity.this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_CODE);
				}
			})
			.setNegativeButton("Tidak Usah", null)
			.create().show();
		} else {
			ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_CODE);
		}
	} else {
		izin = true;
	}
}

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults)
{
	// TODO: Implement this method
	if(requestCode == PERMISSION_CODE){
		if(grantResults.length>0&&grantResults[0]==PackageManager.PERMISSION_DENIED){
			Toast.makeText(getApplicationContext(), "Beberapa fungsi aplikasi mungkin tidak bekerja!", Toast.LENGTH_SHORT).show();
		}
		izin = false;
	} else {
		izin = true;
	}
}

}

main.xml:

<?xml version="1.0" encoding="utf-8"?>
<TabHost
	android:id="@+id/tab_h"
	android:layout_width="match_parent"
	android:layout_height="match_parent">

	<LinearLayout
		android:layout_width="match_parent"
		android:layout_height="match_parent"
		android:orientation="vertical">

		<TabWidget
			android:id="@android:id/tabs"
			android:layout_width="match_parent"
			android:layout_height="wrap_content">

		</TabWidget>

		<FrameLayout
			android:id="@android:id/tabcontent"
			android:layout_width="match_parent"
			android:layout_height="match_parent">

			<LinearLayout
				android:id="@+id/tab1"
				android:layout_width="match_parent"
				android:layout_height="match_parent"
				android:orientation="vertical"
				android:gravity="top|left">

				<LinearLayout
					android:layout_height="wrap_content"
					android:layout_width="match_parent"
					android:orientation="horizontal"
					android:layout_marginTop="10dp">

					<Switch
						android:layout_height="wrap_content"
						android:layout_width="wrap_content"
						android:id="@+id/switch_hari_ini"
						android:onClick="ketuk_hari_ini"/>

					<TextView
						android:layout_height="wrap_content"
						android:textAppearance="?android:attr/textAppearanceMedium"
						android:layout_width="wrap_content"
						android:text="Hari Ini"
						android:layout_gravity="center"
						android:textColor="#000000"/>

				</LinearLayout>

				<LinearLayout
					android:layout_height="wrap_content"
					android:layout_width="match_parent"
					android:orientation="horizontal"
					android:id="@+id/layout_waktu">

					<EditText
						android:layout_width="wrap_content"
						android:layout_height="wrap_content"
						android:hint="Tanggal"
						android:inputType="number"
						android:maxLines="1"
						android:id="@+id/tanggal"/>

					<AutoCompleteTextView
						android:layout_width="150dp"
						android:layout_height="wrap_content"
						android:hint="Bulan"
						android:maxLines="1"
						android:inputType="text|textCapWords"
						android:id="@+id/bulan"/>

					<EditText
						android:layout_width="wrap_content"
						android:layout_height="wrap_content"
						android:hint="Tahun"
						android:maxLines="1"
						android:inputType="number"
						android:id="@+id/tahun"/>

				</LinearLayout>

				<EditText
					android:layout_height="wrap_content"
					android:layout_width="match_parent"
					android:ems="10"
					android:hint="Uang Masuk"
					android:maxLines="1"
					android:inputType="number"
					android:id="@+id/uang_masuk"/>

				<EditText
					android:layout_height="wrap_content"
					android:layout_width="match_parent"
					android:ems="10"
					android:hint="Uang Keluar"
					android:maxLines="1"
					android:inputType="number"
					android:id="@+id/uang_keluar"/>

				<EditText
					android:layout_height="wrap_content"
					android:layout_width="match_parent"
					android:ems="10"
					android:hint="Keterangan"
					android:maxLines="5"
					android:inputType="text"
					android:id="@+id/keterangan"/>

				<Button
					android:layout_height="wrap_content"
					android:layout_width="wrap_content"
					android:text="Simpan Laporan"
					android:id="@+id/button_simpan"
					android:onClick="ketuk_simpan"/>

				<TextView
					android:layout_height="wrap_content"
					android:textAppearance="?android:attr/textAppearanceMedium"
					android:layout_width="wrap_content"
					android:text="Catatan: Untuk jumlah uang silahkan langsung ditulis nominal tanpa titik dan Rp."
					android:layout_marginTop="10dp"
					android:id="@+id/text_keterangan"/>

			</LinearLayout>

			<LinearLayout
				android:id="@+id/tab2"
				android:layout_width="match_parent"
				android:layout_height="match_parent"
				android:gravity="center">

				<TextView
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:text="Tab 2"/>
				
			</LinearLayout>

			<LinearLayout
				android:id="@+id/tab3"
				android:layout_width="match_parent"
				android:layout_height="match_parent"
				android:gravity="center">

				<TextView
					android:layout_width="wrap_content"
					android:layout_height="wrap_content"
					android:text="Tab 3"/>

			</LinearLayout>

		</FrameLayout>

	</LinearLayout>

</TabHost>

LogCat:
BufferQueueProducer
[jund.fauz.lk/jund.fauz.lk.MainActivity] allocateBuffers: slot 3 without buffer is not FREE

Please, help me!

Screenshot of your app’s build.gradle file. Try to include the whole file in the screenshot, i.e. max zoom out inside the file

Oh, sorry. But it has solved :grin:. It just because i didn’t add permission in the manifest file.