【问题标题】:Cannot find symbol variable when building apk构建apk时找不到符号变量
【发布时间】:2018-02-24 09:44:13
【问题描述】:

我在尝试构建发行版 apk 时收到错误消息,这只是在我将构建变体更改为 release 而不是 debug 后才开始发生的。

所以我查看了this post 并查看了所有可能导致我的错误的事情,但我似乎无法找到我的代码的问题。 我假设这篇文章将被标记为重复,但我更喜欢让另一个程序员查看我的代码,然后我可以从那里解决问题。如果有人能为我做到这一点,我将不胜感激。这是代码、我从 Gradle 构建和导入库中收到的错误:

public class LoginActivity extends AppCompatActivity {
private static final String TAG = LoginActivity.class.getSimpleName();
private Button mbtnLogin;
private Button mbtnForgetPassword;
private TextView mTextStateOnline;
private EditText minputEmail;
private EditText minputPassword;
private ProgressDialog mpDialog;
private Switch mSwitch;
public static SQLiteHandler sDb;
public static FileManager fileManager;
public static User sUserco;
public static int sRank;
public static boolean sOnline=true;


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

    //-----------------Set up manager--------------
    fileManager = new FileManager(this);

    //-----------------Find View--------------
    minputEmail = (EditText) findViewById(R.id.email);
    minputPassword = (EditText) findViewById(R.id.password);
    mbtnLogin = (Button) findViewById(R.id.btnLogin);
    mbtnForgetPassword = (Button) findViewById (R.id.Login_forget_pasword);
    mTextStateOnline = (TextView) findViewById(R.id.Login_state_online);
    mSwitch = (Switch) findViewById(R.id.switch2);

来自 Gradle 构建的消息:

M:\Live Projects\IT\Projects\Ghana app\Source Code\Mednet_Ghana\app\src\main\java\co\uk\mednet\mednet_ghana\activity\LoginActivity.java
Error:(81, 32) error: cannot find symbol variable activity_login
Error:(87, 51) error: cannot find symbol variable email
Error:(88, 54) error: cannot find symbol variable password
Error:(89, 47) error: cannot find symbol variable btnLogin
Error:(90, 57) error: cannot find symbol variable Login_forget_pasword
Error:(91, 56) error: cannot find symbol variable Login_state_online
Error:(92, 45) error: cannot find symbol variable switch2

导入库:

import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.Switch;
import android.widget.TextClock;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.Request.Method;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.google.gson.Gson;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import co.uk.mednet.mednet_ghana.R;
import co.uk.mednet.mednet_ghana.app.AppConfig;
import co.uk.mednet.mednet_ghana.app.AppController;
import co.uk.mednet.mednet_ghana.helper.FileManager;
import co.uk.mednet.mednet_ghana.helper.SQLiteHandler;
import co.uk.mednet.mednet_ghana.model.Answer;
import co.uk.mednet.mednet_ghana.model.AssessmentFile;
import co.uk.mednet.mednet_ghana.model.Lesson;
import co.uk.mednet.mednet_ghana.model.Question;
import co.uk.mednet.mednet_ghana.model.User;

【问题讨论】:

  • 也发布您的导入库。我认为您有静态导入(它会导致视图可能不在您当前的布局文件中)如果是,请删除这可能会对您有所帮助。
  • 这可能对你有帮助:stackoverflow.com/q/17241855/4146722
  • 干净-重建你的IDE
  • 抱歉,这些建议都没有奏效

标签: android apk


【解决方案1】:

我只是通过转到我的Project_Name\Module_Name\build\outputs\apk\ 来解决这个问题。然后我删除了那里的apk,重新启动了android studio并转到Build>Generate Signed APK。我选择了Generate Signed APK,因为这是我将 APK 上传到 Google Play Console 所需要的。我确信这可以转移到同一个问题,只要您构建 Apk 而不是需要更多步骤的签名 apk。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-02
    • 1970-01-01
    • 2020-08-12
    • 1970-01-01
    • 2015-09-14
    • 2016-07-01
    • 2016-03-27
    • 2010-10-12
    相关资源
    最近更新 更多