顯示具有 error 標籤的文章。 顯示所有文章
顯示具有 error 標籤的文章。 顯示所有文章

2016年8月17日 星期三

[VC++] Visual Studio 2005 搭配win7 相容性錯誤的解決方法

已知VS2005安裝在win7會有相容性問題,該怎麼解決網路上也有各種說法

但最後解決的辦法是看到stackoverflow上面的這篇文章:

http://stackoverflow.com/questions/1901492/windows-7-visual-studio-2005-compatibility




I had a similar problem when I was installing Visual Studio 2005 Professional on a Windows 7 machine. But here is what I did to fix the problem:
  1. Install Visual Studio 2005 Professional During the install, a window popped up saying that VS2005 might not be compatible with Windows 7. Ignore this warning and continue.
  2. Install Microsoft® Visual Studio® 2005 Team Suite Service Pack 1 VS80sp1-KB926601-X86-ENU.exe Link: Microsoft® Visual Studio® 2005 Team Suite Service Pack 1
  3. Install Visual Studio 2005 Service Pack 1 Update for Windows Vista VS80sp1-KB932232-X86-ENU.exe Link: Visual Studio 2005 Service Pack 1 Update for Windows Vista
Note: If you try and install #3 before #2, you will end up with a message that says : "The upgrade patch cannot be installed by the Windows Installer service because the program to be upgraded may be missing, or the upgrade patch may update a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade patch."
Hope it helps.


看看這邊的回應,他是說先安裝VS2005 然後安裝team suite 最後才安裝SP1 update(順序不要搞混)

不然會出現已經安裝新版本之類的錯誤訊息


附上兩個連結 ,就這樣! end

2016年5月3日 星期二

[C++] WIA with VC++ 無法解析的外部符號 / 解決方法

在寫WIA的時候遇到了一個很棘手的問題,

大概錯誤訊息如:

error LNK2001: unresolved external symbol _CLSID_WiaDevMgr
error LNK2001: unresolved external symbol _IID_IWiaDevMgr

找了三天還是沒結果,後來才了解,解法:



就是這樣,在Project裡面的連結器(Linker)-->輸入(input)-->其它相依性輸入"WiaGuid.Lib"

問題解決! (記錄起來以免忘記)


END

2016年4月26日 星期二

[C++] Messagebox with int/long value , or text 如何顯示?

Debug時候,有時需要使用Messagebox,

但是要加入特定文字,或是變數該怎麼讓他顯示呢?

先從文字開始:

MessageBox(HWND hwnd, LPCWSTR lpText,LPCWSTR lpCation , UINT uType);

hwnd因為不需要特別設定 = 0

LPCWSTR  lpText是Box內想說的話 --->    _T("我想說的話")

LPCWSTR  lpCation是Box的標題 --->    _T("我的標題")

UINT uType 就是可以讓他選OK cancel等按鈕,這邊是填入MB_OK(可以自行調整)





我要填入ulong / int  怎麼辦??

CString msg;
msg.Format(_T("%d").變數名稱);
AfxMessageBox(msg);


這樣就可以囉!


END






2015年8月21日 星期五

[iOS] 上架須知

終於把iOS App上架了!

上架需要的幾個步驟花了我不少時間,在這邊記錄一下以免忘記

step1 : (當然首先已經有帳號了)

https://itunesconnect.apple.com/WebObjects/iTunesConnect.woa/wa/signOutCompleted

進入itunes connect 選擇 我的app



選左上角的+號,就會有出現一串需要設定的包刮icon,版權,截圖等等.....

特別需要注意的就是截圖,

如果你的版本支援5.5吋(iphone 6 plus),4.7吋(iphone 6),4吋(5/5s),3.5吋(4/4s)的話,

那必須要把這些截圖都對應尺寸放上去,否則是無法通關的!

接下來就是程式上傳,該如何上傳呢??

這邊是使用xcode 6.x上傳,以下為示範


在模擬器的部份必須要選擇iOS Device,然後才能在product 選擇 Archieve *沒選的話會變

成灰色不能按

在build/version的部份 也必須要特別注意(圖片中間偏右邊可以看到)

如果你已經上傳同一個version / build的話,那當然就是不能重複上傳,不然會有error!

進入到archieve的部份代表上傳已經完成到一半了(如果沒有錯誤就上傳完成,回到itunes

connect,選擇版本然後就可以上傳,不過需要花一些些時間才看的到,剛開始上傳是看不到

的)

這邊遇到一些問題ex: need 120x 120 icon 之類的



app icon + launch Image 這幾個是一定要填入的icon,

可以透過這個網站來製作


可以看一下是否有images.xcassets的警告,如果有很可能會過不了!

都完成以後,就可以順利上架囉! 審核時間還不確定多長,只能說一定比android長!


2015年6月4日 星期四

[iOS] NSData NSMutableData append / NSString to Char 等問題解法

不是我要說iOS,轉來轉去每個都好麻煩0rz

好吧!

首先,這邊目標是:結合NSString + char[] ,最後變成NSData輸出

NSString *myString = @"123abcdfhhhhhhh";
char *aa = [myString UTF8String];

NSLog(@"%s",aa);
NSLog(@"%lu",sizeof(aa));

NSLog(@"%lu",(unsigned long)[myString length]);

這邊設定一個string ,然後讓他轉utf8格式放到char指標裡面


nslog會顯示

2015-06-04 15:55:32.897 v1.0[4462:60b] 123abcdfhhhhhhh
2015-06-04 15:55:32.898 v1.0[4462:60b] 4

2015-06-04 15:55:32.900 v1.0[4462:60b] 15

所以要特別注意sizeof()並不是mystring分開後的個數,而是4byte 

因為這個錯誤搞了半天0rz.....

到這邊已經很順利的把nsstring 改為char了,但是要怎樣把這兩樣結合呢?


    const unsigned char two[]    = {80 ,67 ,77 ,83 , 2 ,2};//第二個char[]
    
    NSMutableData * muData = [[NSMutableData alloc] init];//用來結合的容器
    
    NSMutableData * data = [NSData dataWithBytes:two length:sizeof(two)];
    NSMutableData * data2 = [NSData dataWithBytes:aa length:[myString length]];//這邊要用length


------------------結合--------------------

   [muData appendData:data];
   [muData appendData:data2];

------------------結合--------------------

    NSString *strData = [[NSString alloc]initWithData:muData encoding:NSUTF8StringEncoding];
   
    NSLog(@"%@",strData);

最後輸出成NSString 方便nslog看成果為如何?


2015-06-04 15:55:43.650 v1.0[4462:60b] PCMS123abcdfhhhhhhh


最後使用


NSData *aData = [strData dataUsingEncoding: NSASCIIStringEncoding];

轉為NSData~


完成!

end

2015年5月26日 星期二

[iOS]NSString & EXC_BAD_ACCESS ERROR solution

問題:

使用全域變數NSString *string,使用時候出現exc_BAD_ACCESS???


答案:


@property (nonatomic,retain)NSString *string;

不可以使用assign 要使用retain!


解決!

end

[iOS] Switch Case Error : switch case in protected scope

錯誤代碼:switch case in protected scope

解決方法:

case 1:

{
    code....

}

break;

case 2:

{
   code2....
 
}

break;


解決! end

2015年5月7日 星期四

[iOS] 改變文字顏色,無效?解決方式

在調整UI的時候常常需要改變顏色

可是使用[UIColor colorwithRed:  green: blue: alpha: ]為什麼輸入數值都沒有反應呢?


錯誤示範:[UIColor colorwithRed: 24 green:116 blue:250  alpha:1 ]

正確示範:[UIColor colorWithRed:24.0f/255.0f green:116.0f/255.0f blue:205.0f/255.0f alpha:1.0f];

需要除以255而且他是float喔!

改完以後就會正確顯示顏色了,簡單但是不知道會弄很久的功能!


end

2015年5月6日 星期三

[iOS] Xcode裡面xib檔內的物件改名後產生NSUnknowkeyException的錯誤解決方法

今天在做ios app的時候又發生了一個悲劇....


看到.h檔裡面的英文拼錯,於是就順手改一下...然後就error!!


找了很久以後,才發現錯誤出現在這邊------



看到Referencing Outlets這邊,

這邊是已經修改過的,如果錯誤的話應該會reference到兩個一個是拼錯字的

另一個才是正確的,我們需要把錯誤的按一下連線的那邊有個x,按下去以後就解除reference

這樣錯誤就修改完成囉!


End

2015年1月22日 星期四

[Android] "ClassNotFoundException" / " Binary XML file line # : Error inflating class” / " multiple dex files define"錯誤解決

在寫Android的時候會使用到別人所用的library,

常常會看到ClassNotFound or Binary XML line #數字 Error inflating class

他的意思就是說(如果我沒有會錯意的話)  :他找不到你import的那個library

為什麼呢?

可能性有幾種(我目前知道解決方式也只有兩種,所以就列出兩種)


1) 你沒有正確import Library


請確定這裡面有打勾了,而不是紅色的X (如果沒有正確import就remove掉重新import一次)



通常新建的專案都會有內建android-support-v4.jar 但是你library又有一份,所以就class not found

exception ,因為她不知道要用哪一個(應該是這樣吧?)

這個就簡單一點,把lib資料夾裡面的android-support-v4.jar 刪除就可以了!

當然會造成classnotfoundexception 跟 error inflating class可能原因有很多,只列舉我找到的解決

方式,紀錄一下 End



補充: multiple dex files define 也是有可能有重複的android-support-v4.jar(刪除即可)

2015年1月14日 星期三

[Android] 基礎Google Map教學

終於把這個很煩人的google map弄出一點樣子

寫在這邊紀錄一下

可能會產生的錯誤會有幾種

1)  INSTALL_FAILED_MISSING_SHARED_LIBRARY Error

2) API Key failed

3) Permission denied



第一種很顯然你刷機(flash ROM)時候法google libary沒有匯入

第二種則是API Key你沒有用你專屬的key ->請到 https://console.developers.google.com/ 申請一

個,申請詳細辦法






切記!!! 你的package name要正確,不正確會無法顯示地圖!!

就把SHA1;package.name輸入在空格中,建立,然後就有API key了

第三種解決方式就是檢查你的AndroidManifest.xml是否有加入適當的permission


-------------------------------------------------------------------------------------------------------------------


以下為三項基礎

1.google play library

首先開啟SDK Manager ->檢查google play service (以下用圖來表示)








有錯誤一定是沒有import正確 / 沒有加入external jar files

然後



這部分需要開啟權限




最後原本的網址載點在這邊

https://github.com/googlemaps/hellomap-android

程式碼跟layout可以上去下載來看看

layout:

<?xml version="1.0" encoding="utf-8"?>
<!--
See this page for more XML attribute options
https://developers.google.com/maps/documentation/android/map#using_xml_attributes
-->
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:map="http://schemas.android.com/apk/res-auto"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.SupportMapFragment"
          map:mapType="normal"/>




MainActivity:

package com.example.hellomap;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;

public class MainActivity extends FragmentActivity {
    private GoogleMap mMap;

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


就這樣! 

完成圖 End

2015年1月8日 星期四

[Android] 長按切換2個Activity-----intent.setClass錯誤排除-----onGestureListener監聽手勢


為了讓兩個activity能夠順利切換,花了一些時間研究,

當然中間也遇到一些問題,在這邊紀錄一下.


首先切換Activity是使用intent->startActivity()來做切換

觸發則是長按畫面任意地方


首先先看如何監聽手勢(gesture):

OnGestureListener listener = new OnGestureListener(){

@Override
public boolean onDown(MotionEvent e) {
// TODO Auto-generated method stub
return false;
}

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2,
float velocityX, float velocityY) {
// TODO Auto-generated method stub
return false;
}

@Override
public void onLongPress(MotionEvent e) {
// TODO Auto-generated method stub
       Intent intent = new Intent();
       intent.setClass(MainActivity.this, switch_target.class);
       startActivity(intent);
       overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
       MainActivity.this.finish();
}

@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
// TODO Auto-generated method stub
return false;
}

@Override
public void onShowPress(MotionEvent e) {
// TODO Auto-generated method stub

}

@Override
public boolean onSingleTapUp(MotionEvent e) {
// TODO Auto-generated method stub
return false;
}};


別忘記要import 所需要的東西

import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;



動畫的部分,首先要在res/anim裡面新增兩個xml檔

第一個檔,檔名隨意設定
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
    <scale
        android:interpolator="@android:anim/linear_interpolator"
        android:fromXScale="0.0"
        android:toXScale="1.0"
        android:fromYScale="0.7"
        android:toYScale="1.0"
        android:fillAfter="false"
        android:startOffset="200"
        android:duration="200" />
    <translate
        android:fromXDelta="50%"
        android:toXDelta="0"
        android:startOffset="200"
        android:duration="200"/>
</set>


第二個檔也是檔名隨意設定


有了動畫xml檔 + 手勢(觸發事件),我們還缺一樣東西,就是切換activity


       Intent intent = new Intent();
       intent.setClass(MainActivity.this, switch_target.class);
       startActivity(intent);
       overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
       MainActivity.this.finish();

切換Activity需要的就是intent,注意這邊

intent.setClass(MainActivity.this, switch_target.class);

是MainActivity.this, switch_target.class兩者是不一樣的,請不要搞錯了(搞錯他就會一直報錯)

 

The method setClass(Context, Class<?>) in the type Intent is not applicable for the arguments...............


這樣的錯誤訊息


另一端切換回來則是:

       Intent intent = new Intent();
       intent.setClass(switch_target.this,MainActivity.class);
       startActivity(intent);
       overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
       switch_target.this.finish();


當然為了避免還是有人看了以後還是出錯,這邊也附上source code 方便大家看

這次的教學就到此囉 End

2014年9月24日 星期三

[Android] ViewPager 遇到在不同xml , 呼叫非setContentView內的R.id.物件 之解決方式

最近在改良Android的APP,先是view flipper,然後現在進階到view pager。

ViewPager可以作出很棒的特效,問題就是在xml方面,如果你要設定物件的話就必須要先

findViewbyId(),這乍聽之下沒甚麼問題,可是假如不是在main.xml檔(主要的xml)的物件呢?

我們使用findViewById()還是可以找到R.id.物件名稱,但只要你一使用的話就會出現錯誤-

java.lang.IllegalState...... NullPointerException....等等。為什麼會出現這樣的錯誤呢?

答案是因為你呼叫的id不在現在的頁面上(Android抓不到他)因此就出現nullpointerException!

在寫的時候也遇到這樣的問題,因此就上網查查看有沒有人也遇到這樣的問題?

發現這篇: 這裡

大意就是說

1.先宣告一個全域變數: private View currentViewPage

2.在 public class MyViewPagerAdapter extends PagerAdapter {} 裡面加入

  @Override
public void setPrimaryItem(ViewGroup container, int position,
Object object) {
currentViewPage = (View) object;
}

也就是把現在的position的object轉型成view然後放入currentViewPage(第一步驟設定的變數)裡

面。

3.最後   IP_edt = (EditText) currentViewPage.findViewById(R.id.IP_edt01);
      IP_edt.setText("123");

就可以用了喔!(當然IP_edt已經在前面有宣告過了)


希望可以幫助也同樣遇到困難的人!






2014年5月14日 星期三

[Android APP] 初探Android APP開發

首先,

前面文章有寫過如何安裝 在這篇, 在經過幾次範例練習後大概有一些心得。

先寫起來以免忘記,當然都是一些基本觀念(新手容易犯的錯誤)

1.專案開起來後設計圖形介面錯誤

正確路徑檔案是在: res資料夾->layout->activity_main.xml 而不是 Fragment_main.xml

(如果寫在Fragment_main.xml會造成java.lang.null point exception 因為它找不到)

2.變數宣告位置錯誤

新手往往會有一個錯誤就是宣告變數再protected void onCreate()的裡面,

但是當這App還沒有被創建時候,是沒有這變數,因此也會造成錯誤,切記切記。

3. 遇到 " error: No resource identifier found for attribute "類似這樣的問題,有可能是更改最底層的Layout

造成的問題(id為container的layout),可以嘗試按右鍵選擇Change Layout,有機會可以去除掉錯誤。

4.在implement監聽物件的時候,MainActivity會需要 -> add unimplement method (程式碼旁邊會有一

個小燈泡,按下去會有這選項)他會幫你新增onXXXChange()這個函式(如果要自己輸入,記得上方

要加入@override,不然還是會有錯)



(未完待續.....)