Gradle错误无法在null对象上调用方法依赖项()

问题描述 投票:1回答:1

我正在为健身房建立一个社交应用程序。此应用程序通过webmethods连接到C#Web应用程序。我经过大量的调试后试图调用ksoap2-android-assembly-3.0.0-RC.2-jar-with-dependencies.jarand,我想出了这个Register类:

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'时出现问题。

无法在null对象上调用方法依赖项()

在此先感谢您的任何帮助。

android gradle dependencies ksoap2 invoke
1个回答
1
投票

你应该只有一个dependencies block,或者至少是}和随后的dependencies {之间的换行符。

如果您这样做会发生什么:

    dependencies {
        compile files('ksoap2-android-assembly-3.0.0-jar-with-dependencies.jar')
        compile 'com.android.support:appcompat-v7:+'
    }
© www.soinside.com 2019 - 2024. All rights reserved.