Saturday, 7 October 2017

Android application is not working

I have been trying to run my client/server android program. But whenever I run the client part on android it gives an error Unfortunately your applicatiopn has stopped running. I have tried reading the logcat but havent been able to fix the problem. below is my code... I have been trying from 3 days. Need help with the project



logcat




12-06 21:05:19.948: D/AndroidRuntime(2136): Shutting down VM
12-06 21:05:19.948: W/dalvikvm(2136): threadid=1: thread exiting with uncaught exception (group=0xa4cf8b20)
12-06 21:05:19.980: E/AndroidRuntime(2136): FATAL EXCEPTION: main
12-06 21:05:19.980: E/AndroidRuntime(2136): Process: com.example.simpleclientapp, PID: 2136
12-06 21:05:19.980: E/AndroidRuntime(2136): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.simpleclientapp/com.example.simpleclientapp.New_main_activity}: android.view.InflateException: Binary XML file line #1: Error inflating class linearlayout
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.app.ActivityThread.access$800(ActivityThread.java:135)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.os.Handler.dispatchMessage(Handler.java:102)

12-06 21:05:19.980: E/AndroidRuntime(2136): at android.os.Looper.loop(Looper.java:136)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.app.ActivityThread.main(ActivityThread.java:5001)
12-06 21:05:19.980: E/AndroidRuntime(2136): at java.lang.reflect.Method.invokeNative(Native Method)
12-06 21:05:19.980: E/AndroidRuntime(2136): at java.lang.reflect.Method.invoke(Method.java:515)
12-06 21:05:19.980: E/AndroidRuntime(2136): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
12-06 21:05:19.980: E/AndroidRuntime(2136): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
12-06 21:05:19.980: E/AndroidRuntime(2136): at dalvik.system.NativeStart.main(Native Method)
12-06 21:05:19.980: E/AndroidRuntime(2136): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class linearlayout
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.view.LayoutInflater.inflate(LayoutInflater.java:469)

12-06 21:05:19.980: E/AndroidRuntime(2136): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
12-06 21:05:19.980: E/AndroidRuntime(2136): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.app.Activity.setContentView(Activity.java:1929)
12-06 21:05:19.980: E/AndroidRuntime(2136): at com.example.simpleclientapp.New_main_activity.onCreate(New_main_activity.java:33)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.app.Activity.performCreate(Activity.java:5231)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
12-06 21:05:19.980: E/AndroidRuntime(2136): ... 11 more
12-06 21:05:19.980: E/AndroidRuntime(2136): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.linearlayout" on path: DexPathList[[zip file "/data/app/com.example.simpleclientapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.simpleclientapp-2, /system/lib]]

12-06 21:05:19.980: E/AndroidRuntime(2136): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
12-06 21:05:19.980: E/AndroidRuntime(2136): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
12-06 21:05:19.980: E/AndroidRuntime(2136): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.view.LayoutInflater.createView(LayoutInflater.java:559)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:652)
12-06 21:05:19.980: E/AndroidRuntime(2136): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
12-06 21:05:19.980: E/AndroidRuntime(2136): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
12-06 21:05:19.980: E/AndroidRuntime(2136): ... 20 more`



activity_new_main_activity.xml



   






manifest.xml



            android:minSdkVersion="10"
android:targetSdkVersion="21" />






android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >


android:name=".New_main_activity"
android:label="@string/title_activity_new_main_activity" >












new_main_activity.java



package com.example.simpleclientapp;

import java.io.BufferedInputStream;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.lang.*;
import java.lang.annotation.*;
import java.lang.ref.*;


import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class New_main_activity extends Activity
{
private Socket client;
private FileInputStream fileInputStream;

private BufferedInputStream bufferedInputStream;
private OutputStream outputStream;
private Button button;
private TextView text;

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_new_main_activity);


button = (Button) findViewById(R.id.button1); //reference to the send button
text = (TextView) findViewById(R.id.textView1); //reference to the text view

//Button press event listener
button.setOnClickListener(new View.OnClickListener()
{

public void onClick(View v)
{



File file = new File("/mnt/shared/sharedwithemulatot/numbers.txt"); //create file instance

try
{
client = new Socket("127.0.0.1", 6443);

byte[] mybytearray = new byte[(int) file.length()]; //create a byte array to file


fileInputStream = new FileInputStream(file);
bufferedInputStream = new BufferedInputStream(fileInputStream);

bufferedInputStream.read(mybytearray, 0, mybytearray.length); //read the file

outputStream = client.getOutputStream();

outputStream.write(mybytearray, 0, mybytearray.length); //write file to the output stream byte by byte
outputStream.flush();
bufferedInputStream.close();

outputStream.close();
client.close();

text.setText("File Sent");


} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();

}


}
});

}
}

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...