2014-04-29 25 views
0

我正在爲健身房構建社交應用程序。此應用程序通過webmethods連接到C#web應用程序。我想打電話給ksoap2-android-assembly-3.0.0-RC.2-jar-with-dependencies.jar和大量的調試後,我想出了這個註冊類:Gradle錯誤無法在空對象上調用方法依賴項()

package com.aaa.ifitapp; 


import android.app.Activity; 
import android.os.Bundle; 
import android.os.StrictMode; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.RadioButton; 
import android.widget.RadioGroup; 
import android.widget.TextView; 

import org.ksoap2.SoapEnvelope; 
import org.ksoap2.serialization.SoapObject; 
import org.ksoap2.serialization.SoapSerializationEnvelope; 
import org.ksoap2.transport.HttpTransportSE; 
import org.xmlpull.v1.XmlPullParserException; 

import java.io.IOException; 


/** 
* Created by Ayman on 3/28/14. 
*/ 
public class Register extends Activity { 
    EditText txtname,txtemail,txtbdate,txtadres,txtphone,txtmsg; 
    TextView txtg; 
    Button btnregister; 
    RadioGroup gendergrpbtn; 
    RadioButton mrbtn,frbtn; 

    private void Initialize(){ 

     txtg =(EditText) findViewById(R.id.gtxt); 

     txtname =(EditText) findViewById(R.id.fullnametxt); 
     txtemail =(EditText) findViewById(R.id.remailtxt); 
     txtbdate =(EditText) findViewById(R.id.agetxt); 
     txtadres =(EditText) findViewById(R.id.addresstxt); 
     txtphone =(EditText) findViewById(R.id.phonetxt); 
     txtmsg =(EditText) findViewById(R.id.msgtxt); 
     btnregister =(Button) findViewById(R.id.signupbtn); 
     mrbtn =(RadioButton) findViewById(R.id.rdobtnm); 
     frbtn =(RadioButton) findViewById(R.id.rdobtnf); 
     gendergrpbtn = (RadioGroup) findViewById(R.id.genderrbtn); 
     btnregister.setOnClickListener(BtnRegist); 

     gendergrpbtn.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener(){ 

       @Override 
       public void onCheckedChanged(RadioGroup arg0, int arg1) { 
        if(frbtn.isChecked()){ 
         txtg.setText("f"); 
        } 
        else{ 
         mrbtn.isChecked(); 
         txtg.setText("m"); 

        } 
       }}); 
    } 

    View.OnClickListener BtnRegist=new View.OnClickListener() { 
     @Override 
     public void onClick(View view) { 

      StrictMode.ThreadPolicy policy= 
        new StrictMode.ThreadPolicy.Builder().permitAll().build(); 
      StrictMode.setThreadPolicy(policy); 
      SoapObject request = new SoapObject("http://ifitness.com/adminservice","register"); 

     request.addProperty("fullname",txtname.getText().toString()); 
      request.addProperty("email",txtemail.getText().toString()); 
      request.addProperty("address",txtadres.getText().toString()); 
      request.addProperty("gender", txtg.getText().toString());; 
      request.addProperty("bdate",txtbdate.getText().toString()); 
      request.addProperty("phone", txtname.getText().toString()); 
      request.addProperty("image",txtname.getText().toString()); 

      SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER12); 
      envelope.dotNet=true; 
      envelope.setOutputSoapObject(request); 
      HttpTransportSE transport= 
        new HttpTransportSE("http://10.0.2.2:1469/IFitService.asmx?WSDL"); 
      try { 
       transport.call("http://ifitness.com/adminservice/register",envelope); 
       txtmsg.setText(envelope.getResponse().toString()); 
      } catch (IOException e) { 
       e.printStackTrace(); 
      } catch (XmlPullParserException e) { 
       e.printStackTrace(); 
      } 


     } 
    }; 

    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_register); 
     Initialize(); 

    } 
} 

我已經調整好自己的build.gradle如下:

buildscript { 
    repositories { 
     mavenCentral() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:0.6.+' 
    } 
} 
apply plugin: 'android' 

repositories { 
    mavenCentral() 
} 

android { 
    compileSdkVersion 18 
    buildToolsVersion "18.1.1" 

    defaultConfig { 
     minSdkVersion 9 
     targetSdkVersion 18 
    } 
} 


dependencies { 
    compile files('ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar') 

}dependencies { 
    compile 'com.android.support:appcompat-v7:+' 

} 

但現在我發生此錯誤:

Gradle:評估項目'IFitApp'時發生問題。

Cannot invoke method dependencies() on null object

在此先感謝您的任何幫助。

回答

1

您應該只有一個dependencies block}和後續的dependencies {之間的換行符。

如果你這樣做,會發生什麼:

dependencies { 
     compile files('ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar'), 
     compile 'com.android.support:appcompat-v7:+' 
    } 
+0

但是當我再之間進行新的生產線這一切墜毀,所有ksoap2錯誤回來 問題是我不知道如何來聲明依賴如COM。 android.support:appcompat-v7:+ – aymashtain

+0

不要在行之間放置「,」字符。抱歉。 – c0d3Junk13

相關問題